noggin

AtomicOp

The discriminated union every state mutation goes through. Verbs compose lists of these and pass them to NogginStore.apply(ops) in a single call. Providers execute the list atomically — either every op lands or none do.

type AtomicOp = 
  | {
  item: Item;
  parentKey: ItemKey | null;
  position: number | "end";
  type: "add";
}
  | {
  keys: readonly ItemKey[];
  type: "remove";
}
  | {
  key: ItemKey;
  patch: {
     done?: boolean;
     title?: string;
  };
  type: "set";
}
  | {
  key: ItemKey;
  note: Note;
  type: "note";
}
  | {
  key: ItemKey;
  parentKey: ItemKey | null;
  position: number | "end";
  type: "move";
}
  | {
  key: ItemKey | null;
  type: "setActive";
};

Atomic state mutations. Every change to a noggin's state goes through one of these. Verbs compose op lists; providers execute them atomically via Noggin.apply(ops).

position is the 0-based index among siblings of parentKey, or the literal string 'end' to append.