diff --git a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/LiveRealm.kt b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/LiveRealm.kt index cd4647b901..01ceeec1a8 100644 --- a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/LiveRealm.kt +++ b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/LiveRealm.kt @@ -67,7 +67,7 @@ internal abstract class LiveRealm( * [gcTrackedSnapshot] then the old reference will be closed, allowing Core to release the * underlying resources of the no-longer referenced version. */ - private val _snapshot: AtomicRef = atomic(realmReference.snapshot(owner)) + private val _snapshot: AtomicRef = atomic(realmReference.snapshot(owner).also { onChange() }) /** * Flag used to control whether to close or track the [_snapshot] when advancing to a newer * version. diff --git a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableNotifier.kt b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableNotifier.kt index 482b0400a6..e4fb98228d 100644 --- a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableNotifier.kt +++ b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableNotifier.kt @@ -76,7 +76,7 @@ internal class SuspendableNotifier( } } - override val realmInitializer = lazy { NotifierRealm().also { onChange() } } + override val realmInitializer = lazy { NotifierRealm() } // Must only be accessed from the dispatchers thread override val realm: LiveRealm by realmInitializer diff --git a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableWriter.kt b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableWriter.kt index cc80f11a76..74c9284649 100644 --- a/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableWriter.kt +++ b/packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/SuspendableWriter.kt @@ -82,7 +82,7 @@ internal class SuspendableWriter( } override val realmInitializer: Lazy = lazy { - WriterRealm().also { onChange() } + WriterRealm() } // Must only be accessed from the dispatchers thread