Fixes errors like ❌ asFlow_objectBound_withKeyPath[jvm] java.lang.IllegalStateException: [RLM_ERR_WRONG_THREAD]: Realm accessed from incorrect thread., but could happen with any KeyPath.
The problem was that we were calling a function in the notifier (from an arbitrary thread), and then using the notifier Realm (outside the notifier thread). So depending on the timing, sometimes it would return a thread-confined Realm.
I refactored the code, so we now calculate the keypath array outside the notifier using the caller Realm which should always be safe.
Fixes errors like
❌ asFlow_objectBound_withKeyPath[jvm] java.lang.IllegalStateException: [RLM_ERR_WRONG_THREAD]: Realm accessed from incorrect thread.
, but could happen with any KeyPath.The problem was that we were calling a function in the notifier (from an arbitrary thread), and then using the notifier Realm (outside the notifier thread). So depending on the timing, sometimes it would return a thread-confined Realm.
I refactored the code, so we now calculate the keypath array outside the notifier using the caller Realm which should always be safe.