Interface: RecordPatchHandlers

x2node-patches. RecordPatchHandlers

Interface for record patch handlers objects that can be invoked when patch operations are applied to a record. Each method is optional and even if present is called only if the patch detects that the operation changes the current record (except the "test" operation).

Methods


onInsert(op, ptr, newValue, oldValue)

Called when a value is added to an array or map property as a result of an "add", "move" or "copy" patch operation.
Parameters:
Name Type Description
op string The operation, which can be "add", "move" or "copy".
ptr module:x2node-pointers~RecordElementPointer Path pointer.
newValue * The value inserted (may be null for a simple value array or map element, but never undefined).
oldValue * Previous value at the location.

onRemove(op, ptr, oldValue)

Called when a value is removed from an array or map property as a result of a "remove" or "move" patch operation.
Parameters:
Name Type Description
op string The operation, which can be "remove" or "move".
ptr module:x2node-pointers~RecordElementPointer Path pointer.
oldValue * Previous value at the location.

onSet(op, ptr, newValue, oldValue)

Called when a value is set to a property as a result of an "add", "remove", "replace", "move" or "copy" patch operation.
Parameters:
Name Type Description
op string The operation, which can be "add", "remove", "replace", "move" or "copy".
ptr module:x2node-pointers~RecordElementPointer Path pointer.
newValue * The new value (may be null but never undefined).
oldValue * Previous value at the location.

onTest(ptr, value, passed)

Called when a property value is tested as a result of a "test" patch operation.
Parameters:
Name Type Description
ptr module:x2node-pointers~RecordElementPointer Path pointer.
value * The value tested (may be null but never undefined).
passed boolean true if the test operation passed.