Skip to content
New issue

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

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

Already on GitHub? # to your account

[Request] Add custom scope open/closing #313

Closed
Anfet opened this issue Feb 17, 2023 · 8 comments
Closed

[Request] Add custom scope open/closing #313

Anfet opened this issue Feb 17, 2023 · 8 comments

Comments

@Anfet
Copy link

Anfet commented Feb 17, 2023

Hi everyone.

With this feature we can tie scopes to stateful widget lifecycle initState/dispose methods.

With current model it's not possible, since widget A can be disposed after Widget B initState is called. Therefor breaking scope destruction.

@subzero911
Copy link

subzero911 commented Mar 30, 2023

Same here, I just got a scope race condition, when I pop scope on widget dispose and register a new singleton on a new screen open, but it gots disposed in a several milliseconds.
I think I'll file a new issue.

@escamoteur
Copy link
Collaborator

Any idea how this should lool like? If you only want to tie a scope to a widgets life cycle, the get_it_mixin would be the more elegant solution.

@Anfet
Copy link
Author

Anfet commented May 2, 2023

Just add a scope name to close function.

@escamoteur
Copy link
Collaborator

Can you elaborate on how you mean that?

@Anfet
Copy link
Author

Anfet commented May 4, 2023

Just add a scopeName to popScope function.

getIt.pushNewScope(scopeName: someScreen);
getIt.popScope(scopeName: someScreen);

This way we can close any open scope.

@escamoteur
Copy link
Collaborator

but that wouldn't be popping but removing a scope anywhere in the stack, or not?

There is actually a PR waiting for that #292

I'm not sure if that would help with the race condition that you observed?

@Anfet
Copy link
Author

Anfet commented May 4, 2023

Yep. Thats exactly what is needed.
Thank you.

@Anfet Anfet closed this as completed May 4, 2023
@escamoteur
Copy link
Collaborator

#316 (comment)

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

No branches or pull requests

3 participants