Skip to content
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

A way to request the current scope #153

Closed
swissonid opened this issue Jan 28, 2021 · 4 comments
Closed

A way to request the current scope #153

swissonid opened this issue Jan 28, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@swissonid
Copy link

Let's say you want to be sure that each time you enter a specific section of your app, that you start a new clean session.
So before you start a new one you wanna check the current scope, to know if it is nesscacy to pop.

Right now something like that:

Future<void> startSession() async {
    final sessionScopeName = 'sesstionScopeName';
    if(getIt.currentScopeName == sessionScopeName) { <-- New Feature 
      await geit.popScope();// to be sure that the old session gets removed
    }
    await pushNewScope(scopeName: sessionScopeName);
}

is not possible and because of the issue #152 you can not relay on any exception. The only way I found was to add ah dummy scope which can be pop without any issue.

So it would be nice to have the option to request the current scope. Or do I overlook something?

@escamoteur
Copy link
Collaborator

I thinks that's an absolute reasonable request. But probably it will be added to the null save version.
In general I would feel quite uncomfortable when I had to check if my app is in a certain state.
If you have to I'm not sure if your app logic is really save.

@xmkevinchen
Copy link

Really looking forward to seeing this enhancement would be in the get_it upcoming release.

Right now, I need to manually check some instances registered or not to determine whether the scope has been pushed or not.

@escamoteur
Copy link
Collaborator

Uh, I somehow forgot about this. will add it soon

@escamoteur
Copy link
Collaborator

Implemented in V6.1.0

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

No branches or pull requests

3 participants