Skip to content

[Question] Is allReady available to Scope #262

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
timnew opened this issue Mar 2, 2022 · 2 comments
Closed

[Question] Is allReady available to Scope #262

timnew opened this issue Mar 2, 2022 · 2 comments

Comments

@timnew
Copy link

timnew commented Mar 2, 2022

allReady is a convenient way to ensure all dependencies are fully initialised. But I found it only works for root scope?

When I pushed a new scope, registered a few async singleton (UserBookRepository in example) in it, and trying to call allReady, I got an error.

I'm asking here is because the error message is very confusing, as I'm calling allReady to wait before every instance is ready. But here it complains I'm accessing an instance before it is ready? Is it kind of against the idea of allReady or I misunderstood something?

════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building Builder:
You tried to access an instance of UserBookRepository that is not ready yet
'package:get_it[/get_it_impl.dart]()':
package:get_it/get_it_impl.dart:1
Failed assertion: line 404 pos 9: 'instanceFactory.isReady'
@timnew timnew closed this as completed Mar 2, 2022
@timnew timnew reopened this Mar 2, 2022
@escamoteur
Copy link
Collaborator

Sorry for the late reply. This should be possible. could you please create a small sample project?

@timnew
Copy link
Author

timnew commented Apr 26, 2022

Hi @escamoteur I failed to reproduce the bug in the UT, as all the tests are green.
And I kind of worked around the issue in the app, but still not 100% sure how and why.
I'll close the issue, unless I found more useful details

@timnew timnew closed this as completed Apr 26, 2022
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