Ability to log lifecycle changes
I would love to be able to track lifecycle changes of classes I instantiate using GetIt or WatchIt.
Something like an observer which can be passed to ProviderScope in Riverpod.
So I can log when some class is instantated, disposed, etc.
Can you elaborate this a bit more? I'm not sure how for what you would use this?
It's used so I can have information about initialization and disposal of various classes in the console.
It's something like a BlocObserver which you can check HERE.
I would like this global 'observer' where I can set that it logs someting like this when it initializes a class with GetIt:
✅ $className INITIALIZED ✅
And when it disposes, I would log something like this:
❌ $className DISPOSED ❌
Does all this make sense?
Adding logging for creation of instances inside get_it like from factories or lazy simpletons or any dependent singletons would be possible but because objects are not always actively disposed the question would be should it be logged if a dispose was called on a registered object? Or if the instance was removed from get_it. Even then we won't know if the object will get garbage collected because there could be another reference.
Whatndo you think makes here the most sense? Am 24. Jan. 2025, 17:45 +0100 schrieb Josip K @.***>:
It's used so I can have information about initialization and disposal of various classes in the console. It's something like a BlocObserver which you can check HERE. I would like this global 'observer' where I can set that it logs someting like this when it initializes a class with GetIt: ✅ $className INITIALIZED ✅ And when it disposes, I would log something like this: ❌ $className DISPOSED ❌ Does all this make sense? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
I would love to have the ability to log when instances get created and when they get disposed. Whatever the reason for disposal is, logging would help me get a better understanding of the lifecycle and general behaviour of instances within my app.
So yeah, adding the ability to use somekind of a global observer would be a cool feature for GetIt and WatchIt. Of course, if the developer doesn't add anything, it will behave without any logs or whatever.
But yeah, having the ability to add a global observer would help me a lot (and others, I'm sure).
The biggest problem is that there is no guaranted disposal but I agree it could be very helpful
+1 I would love to see this