Skip to content

isRegistered is not working #107

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
rdonoso opened this issue Sep 10, 2020 · 2 comments
Closed

isRegistered is not working #107

rdonoso opened this issue Sep 10, 2020 · 2 comments

Comments

@rdonoso
Copy link

rdonoso commented Sep 10, 2020

Hello,

I am trying to use the method to check if a singleton is registered, but it seems that i am doing something wrong.

This is an extract of the code and if i use this way always return false and always throw the exception with the next line that is already registered the singleton
if (!locator.isRegistered(instance: ControlCenterViewModel))

But this way if the instance is not loaded throw an exception, to make sure that ControlCenterViewModel is in get_it.
if (!locator.isRegistered(instance: locator<ControlCenterViewModel>()))

Please help, how i can make this right.

Thanks!

@escamoteur
Copy link
Collaborator

if (!locator.isRegistered(instance: ControlCenterViewModel))

you can't pass a type as instance you should do it like:

if (!locator.isRegistered<ControlCenterViewModel>( ))

@rdonoso
Copy link
Author

rdonoso commented Sep 10, 2020

@escamoteur Thank you! it works!

@rdonoso rdonoso closed this as completed Sep 10, 2020
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