@dxos/echo
    Preparing search index...

    Function update

    • Perform mutations on an echo relation within a controlled context.

      All mutations within the callback are batched and trigger a single notification when the callback completes. Direct mutations outside of Relation.update will throw an error for echo relations.

      Type Parameters

      Parameters

      • relation: T

        The echo relation to mutate. Use Obj.update for objects.

      • callback: ChangeCallback<T>

        The callback that performs mutations on the relation.

      Returns void

      const worksFor = Relation.make(EmployedBy, {
      [Relation.Source]: person,
      [Relation.Target]: company,
      role: 'Engineer',
      });

      // Mutate within Relation.update
      Relation.update(worksFor, (obj) => {
      obj.role = 'Senior Engineer';
      });

      Note: Only accepts relations. Use Obj.update for objects.

      Synchronous; costs the mutations made in the callback plus one batched notification.