Skip to main content

Function: onDeepChange()

function onDeepChange(subtreeRoot, listener): OnDeepChangeDisposer;

Adds a listener that will be called every time a deep change is generated for the tree of the given target object. Unlike onPatches, this provides raw MobX change information including proper splice detection for arrays. Individual mutations notify listeners after automatic type checking succeeds and snapshots update; rejected mutations and their quiet rollbacks do not notify listeners. Listener errors do not stop delivery to other listeners. After delivery completes, a single error is rethrown unchanged and multiple errors are grouped in a MobxKeystoneAggregateError. Listeners added while callbacks for the same target are running start with the next change delivered to that target. Listeners disposed during delivery do not receive the current change if their callback has not run yet.

Parameters​

ParameterTypeDescription
subtreeRootobjectSubtree root object of the deep change listener.
listenerOnDeepChangeListenerThe listener function that will be called every time a change is generated for the object or its children.

Returns​

OnDeepChangeDisposer

A disposer to stop listening to deep changes.