anyone using koin? how do you handle cleaning up? ...
# android-architecture
j
anyone using koin? how do you handle cleaning up? e.g. closing open realm instances on closing app?
d
This is why I don’t use Realm. But how is #koin related to realm lifecycle?
e
I usually don't work with components that require manual cleanup. But I suppose that you could Scope your realm instances and close the scope and do the cleanup at the end of your application lifecycle
👍 1
j
was just wondering how to handle removing listeners with koin in general
scope seems to be solving that
u
btw there is no thing as app closing
j
well activity destroy then ^^
k
Cleaning up realm is not koin's business imho. I would suggest bind clearing to ViewModel scope
We currently use both koin & realm - and don't use realm listeners (except few cursors for long lists, which are cleared with ViewModel). Instead we open & close realm for each request to DB - works pretty stable and quickly
j
we're using realm listeners and transform them to livedata https://github.com/exozet/AndroidCore/blob/master/core/src/main/java/com/exozet/android/core/realm/RealmResultsLiveData.kt https://github.com/exozet/AndroidCore/blob/master/core/src/main/java/com/exozet/android/core/extensions/Realm+Extensions.kt#L9 so that we can run dao.getItems().asLiveData() question was just how to make sure we don't produce leaks etc
120 Views