https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
j

Jan

06/13/2019, 11:58 AM
anyone using koin? how do you handle cleaning up? e.g. closing open realm instances on closing app?
d

dawidhyzy

06/13/2019, 12:15 PM
This is why I don’t use Realm. But how is #koin related to realm lifecycle?
e

Eric Martori

06/13/2019, 1:04 PM
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

Jan

06/13/2019, 1:06 PM
was just wondering how to handle removing listeners with koin in general
scope seems to be solving that
u

ursus

06/14/2019, 5:48 PM
btw there is no thing as app closing
j

Jan

06/17/2019, 9:21 AM
well activity destroy then ^^
k

kzotin

06/18/2019, 10:28 AM
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

Jan

06/18/2019, 12:54 PM
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
59 Views