Hey, is there a way to know when object is no longer available so subscriptions, coroutine scope, etc, can be cancelled?
Like with
ActivityScoped
, when activity is destroyed - in this particular case I could've get an activity with
ActivityContext
and listen to the lifecycle, but this won't work generally, e.g. with
ActivityRetainedScoped
.
The only idea that come to my mind is using
finalize
but it seems to be a bad practice and doesn't seems to be reliable - as I understand there's no guarantee it'll be called on time.
Usually
Closeable
is used in such situations, I've tried implementing it but Dagger doesn't seems to be checking it.