Skip to content

Ability to know registered object's _ServiceFactoryType type #306

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
Tkko opened this issue Dec 22, 2022 · 1 comment
Closed

Ability to know registered object's _ServiceFactoryType type #306

Tkko opened this issue Dec 22, 2022 · 1 comment

Comments

@Tkko
Copy link

Tkko commented Dec 22, 2022

Hey, I'd like to know whether registered object is singleton or not.
Use case:
I have a wrapper widget around Cubit/Bloc which retrieves correct instance of bloc from getIt,
but I have an issue when I'm trying to close/dispose the bloc, there are two cases

  1. Bloc is registered as factory, meaning it okay to close it after its widget disposes
  2. Bloc is Singleton/lazy and I don't want to close it after its widget disposes, but I can't tell if bloc is singleton or not without passing specific parameter to cubit wrapper widget

Possible solution would be to expose _ServiceFactoryType and call getIt.type() or getIt.typeOf<T>()

@escamoteur
Copy link
Collaborator

I know that it's been a long time, but I had to make a longer break due to health issues.
Why not simply add a bool flag inside the Bloc object that tells if it can be disposed? or isn't it clear when the Bloc is created if it's used inside a factory or singleton?

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

No branches or pull requests

2 participants