diff --git a/.changeset/wicked-ties-provide.md b/.changeset/wicked-ties-provide.md new file mode 100644 index 000000000..ddb7681b1 --- /dev/null +++ b/.changeset/wicked-ties-provide.md @@ -0,0 +1,5 @@ +--- +'contexture-client': minor +--- + +Call onUpdateByOthers on properties that have an 'all' reactor diff --git a/packages/client/src/index.js b/packages/client/src/index.js index 93f4244fc..24abee2f9 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -134,14 +134,19 @@ export let ContextTree = _.curry( _.map(snapshot), _.find({ path: snapshot(event.path) }) )(updatedNodes) - if (!affectsSelf) - await Promise.all( - _.map((n) => { + await Promise.all( + _.map( + (n) => { // When updated by others, force replace instead of merge response extend(n, { forceReplaceResponse: true }) runTypeFunction(types, 'onUpdateByOthers', n, actionProps) - }, updatedNodes) + }, + _.remove( + (n) => _.isEqual(snapshot(n.path), snapshot(event.path)), + updatedNodes + ) ) + ) // If disableAutoUpdate but this dispatch affects the target node, update *just* that node (to allow things like paging changes to always go through) // The assumption here is that any event that affects the target node would likely be assumed to take effect immediately by end users