observe

fun <T> observe(readObserver: SnapshotReadObserver? = null, writeObserver: SnapshotWriteObserver? = null, block: () -> T): T

Observe reads and or write of state objects in the current thread.

This only affects the current snapshot (if any) and any new snapshots create from takeSnapshot and takeMutableSnapshot. It will not affect any snapshots previous created even if Snapshot.enter is called in block.

Parameters

readObserver

called when any state object is read.

writeObserver

called when a state object is created or just before it 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.