@dxos/echo
    Preparing search index...

    Function update

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

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

      This function also works with nested objects within echo objects (e.g., Template structs) that are reactive at runtime.

      Type Parameters

      Parameters

      • obj: T

        The echo object to mutate. Use Relation.update for relations.

      • callback: ChangeCallback<T>

        The callback that performs mutations on the object.

      Returns T

      const person = Obj.make(Person, { name: 'John', age: 25 });

      // Mutate within Obj.update
      Obj.update(person, (obj) => {
      obj.name = 'Jane';
      obj.age = 30;
      });
      // ONE notification fires here

      // Direct mutation throws
      person.name = 'Bob'; // Error: Cannot modify outside Obj.update()

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

      Synchronous; costs the mutations made in the callback plus one batched notification and an O(owning fields) parent pass.