Diff structures - HohensteinGroup/ChangeChecker GitHub Wiki

Beware: When creating diffs, only changes of references are taken into account. This means a change will not be detected if only the inner value of a reference changed but not the reference itself.

Diff structures

All custom properties are prefixed with a "$" to avoid name collisions.

ObjectDiff

Every property of the snapshot and the model will be transformed to a PropertyDiff.

$isDeleted

This flag is set to true, if the object is present in the snapshot but not in the model.

$isCreated

This flag is set to true, if the object is not present in the snapshot but in the model.

$isChanged

This flag is set to true, if any properties value or reference has changed.

PropertyDiff

$isChanged

This flag is set to true, if the value, "value like" or reference of the property has changed.

$formerValue

This is the former value, "value like" or reference. If the property referenced an object in the snapshot, $formerValue is bound to the related ObjectDiff.

$value

This is the present value, "value like" or reference. If the property referenced an object in the snapshot or model, $value is bound to the related ObjectDiff

ArrayDiff

$deleted

This property contains all deleted values, "value likes" and the diffs of the deleted objects or arrays.

$inserted

This property contains all inserted values, "value likes" and the diffs of the inserted objects or arrays.

$other

This property contains all values, "value likes" and the diffs of the objects and arrays not in $deleted and $inserted.

$isDeleted

This flag is set to true, if the array is present int the snapshot but not in the model.

$isCreated

This flag is set to true, if the array is not present in the snapshot but in the model.

$isChanged

This flag is set to true, if $deleted or $inserted contains any entry.

Member all structures share

$isDirty()

This function performs a deep dirty check by recursively traversing all child nodes, looking for true $isChanged, $isDeleted, $isCreated fields.

$unwrap(Era.Former | Era.Present)

This function reconstructs the present or former model by recursively traversing all childs choosing the $formerValue or $value of PropertyDiffs and composing $other with $deleted or $inserted for ArrayDiffs.