-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Describe your problem or use case
The Kotlin SDK provides flow events when sets, lists and dictionaries are deleted as part of deleting their parent object. Since core doesn't give any notification of deletion of the actual collection, we have emulated these by listening to deletion of their parent object.
We would like to provide the similar behavior for sets, lists and dictionaries in mixed fields corresponding to offer the functionality highlighted by this test:
val container = realm.write { copyToRealm(JsonStyleRealmObject().apply { value = realmAnySetOf() }) } val mutex = Mutex(true) val flow = async { container.value!!.asSet().asFlow().first { mutex.unlock() it is DeletedSet<*> } } // Await that flow is actually running mutex.lock() // Update mixed value to overwrite and delete set realm.write { findLatest(container)!!.value = realmAnyListOf() } // Await that notifier has signalled the deletion so we are certain that the entity // has been deleted withTimeout(10.seconds) { flow.await() }
This cannot be done following the above approach since for collections in mixed this would require listening for deletion of any parent container type, i.e. which isn't supported by core.
Describe the solution you'd like
Ideally the notification system should just be able to signal deletion of then entity for which the notification listener was registered. This would also allow to eliminate the workaround for conventional collections.
The approach of registering listeners for the parent containing entity does not seem feasible, as collections in mixed opens up for nested collection trees and would require to propagate this all the way to an object root.
Additional context
<!-- Add any other context about the feature request here. -->