Skip to content

How do you wait for factories to be ready #406

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
JoseEsTev opened this issue Apr 17, 2025 · 3 comments
Closed

How do you wait for factories to be ready #406

JoseEsTev opened this issue Apr 17, 2025 · 3 comments

Comments

@JoseEsTev
Copy link

Hello,

I'm registering multiple factories in my app, and on some cases when I launch the app, i get an exception stating that the factory was not registered. But if I add a little delay on purpose using await Future.delayed in my splash screen, this works fine.

@escamoteur
Copy link
Collaborator

Are you really registering factories or async singleons?
Have you read my article https://blog.burkharts.net/lets-get-this-party-started-startup-orchestration-with-getit

@JoseEsTev
Copy link
Author

Are you really registering factories or async singleons? Have you read my article https://blog.burkharts.net/lets-get-this-party-started-startup-orchestration-with-getit

I am registering factories (for cubit creators) and singletons (not async) for repositories. But I get an error stating that a cubit instance could not be retrieved using a factory cause it has not been registered yet.

Since the docs for the factories explain that factories registration occurs immediately, and I am registering them before the piece of code where I try to get this first cubit instance, this should not happen, right?

@escamoteur
Copy link
Collaborator

escamoteur commented Apr 23, 2025

Indeed, if you do the registration as the first thing at startup that should never happen. can you verify with logging that you really don't try to access the cubit before you register it? If not I would need a project that shows that behavior that I could debug

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