SnapshotInstanceObservers


The return result of SnapshotObserver.onCreating allowing the reads and writes performed in the newly created snapshot to be observed

Summary

Public constructors

SnapshotInstanceObservers(
    readObserver: ((Any) -> Unit)?,
    writeObserver: ((Any) -> Unit)?
)
Cmn

Public properties

((Any) -> Unit)?

Called whenever a state is read in the snapshot.

Cmn
((Any) -> Unit)?

Called just before a state object is written to the first time in the snapshot or a nested mutable snapshot.

Cmn

Public constructors

SnapshotInstanceObservers

SnapshotInstanceObservers(
    readObserver: ((Any) -> Unit)? = null,
    writeObserver: ((Any) -> Unit)? = null
)

Public properties

readObserver

val readObserver: ((Any) -> Unit)?

Called whenever a state is read in the snapshot. This is called before the read observer passed to Snapshot.takeSnapshot or Snapshot.takeMutableSnapshot.

This method is called in the same thread that reads snapshot state.

writeObserver

val writeObserver: ((Any) -> Unit)?

Called just before a state object is written to the first time in the snapshot or a nested mutable snapshot. This might be called several times for the same object if nested mutable snapshots are created as the unmodified value may be needed by the nested snapshot so a new copy is created. This is not called for each write, only when the write results in the object be recorded as being modified requiring a copy to be made before the write completes. This is called before the write has been applied to the instance.

This is called before the write observer passed to Snapshot.takeMutableSnapshot.

This method is called in the same thread that writes to the snapshot state.