-
Type:
Task
-
Resolution: Fixed
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
?
-
8
-
118
-
Kotlin Beta sprint 14, Kotlin Beta sprint 15, Kotlin Beta sprint 16, Kotlin Beta sprint 17, Kotlin Beta sprint 18
First draft of this API was added here #107, but this doesn't add support for also providing detailed changes.
There are two orthogonal discussions:
1) How to register and deregister any changelistener?
// Option A: Return "token" like // Same pattern as RxJava // Less API methods on top-level classes class Realm { fun addChangelistener(listener: RealmChangeListener): Cancellable fun cancelAllChangeListeners() // Or maybe introduce something like CompositeCancellable like RxJava } val token = realm.addChangelistener { } token.cancel(); // onDestroy realm.addChangeListener { } realm.cancelAllChangeListeners() // Option B: Java like API // 1 more method in the API // Must define listener in a class variable to be able to cancel listener // Mirrors current Java API class Realm { fun addChangelistener(listener: RealmChangeListener) fun removeChangelistener(listener: RealmChangeListener) fun removeAllChangelisteners() } // Option C: Something else? // ...
2) How should fine-grained notification listeners look like?
class RealmResults { // Option A: Two arguments returned // Depends on autocomplete to work "out-of-the-box" // Top-level access to the collection fun addChangeListener1(listener: (listener: (collection: RealmResults<E>, change: OrderedRealmCollection<E>) -> Unit) { TODO() } // Option B: One argument returned // `it` is available // collection access is one layer away. // Flows only allow one argument. So the API for change listeners and Flows would be consistent fun addChangeListener1(listener: (OrderedCollectionChange<E, RealmResults<E>>) -> Unit) { TODO() } }
- is depended on by
-
RKOTLIN-137 Story: MVP Realm API
- Closed