felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.56k stars 3.37k forks source link

question: BlocObserver and Injectable Singletons #4141

Closed psyfreak closed 3 months ago

psyfreak commented 3 months ago

Question What is the best way to use BlocObserver for logging purpose with the injectable singletons?

Setup I have a BlocObserver logging most of the standard functions such as onCreate, onChange etc. It is working well if my Blocs are annotated as "injectable" or "lazySingleton" but the BlocObserver is not logging for "singleton". When I add for example an onChange(Change change) directly into the bloc it properly logs. My assumption is that singleton blocs are created before the BlocObserver is "alive".

Thank you in advance.

felangel commented 3 months ago

Hi @psyfreak 👋 Thanks for opening an issue!

Can you please share a link to a minimal reproduction sample that illustrates the issue? Thanks!

psyfreak commented 3 months ago

you are welcome. I will, but it may take a while. I also corrected the above. It works with lazySingleton annotation but not with singleton.

felangel commented 3 months ago

Since there's no actionable next steps, I'm going to close this issue but once you have time to create a minimal reproduction sample, let me know and I'm happy to revisit this, thanks!