Skip to content

[Question] - Auto-dispose Singleton when the widget's is unmounted from the widget tree #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dinbtechit opened this issue Dec 5, 2022 · 4 comments

Comments

@dinbtechit
Copy link

dinbtechit commented Dec 5, 2022

Is it possible to automatically unregister a singleton when the widget is unmounted from the widget tree?

@dinbtechit dinbtechit changed the title [Question] - Auto-dispose when the widget's is unmounted from the widget tree [Question] - Auto-dispose Singleton when the widget's is unmounted from the widget tree Dec 5, 2022
@escamoteur
Copy link
Collaborator

yep it is, with the get_it_mixin you can push a scope when a widget is first displayed and dispose the scope with its widgets when the widget is destroyed

@dinbtechit
Copy link
Author

dinbtechit commented Apr 24, 2023

yep it is, with the get_it_mixin you can push a scope when a widget is first displayed and dispose the scope with its widgets when the widget is destroyed

Thank you @escamoteur !! Is there a code example of this?

@escamoteur
Copy link
Collaborator

it's in the readme.

@dinbtechit
Copy link
Author

Perfect thank you!!! 🙏🙏🙏🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants