vapor-chamber API reference - v1.3.0
    Preparing search index...

    Function optimistic

    • Optimistic update plugin - apply optimistic state, rollback on failure.

      Accepts per-action apply functions that optimistically mutate state and return a rollback closure. If the handler (or async resolution) fails, the rollback is called automatically.

      Parameters

      • handlers: Record<string, { apply: (cmd: Command) => (() => void) | null }>

      Returns Plugin

      bus.use(optimistic({
      cartAdd: { apply: (cmd) => { addItem(cmd.target); return () => removeItem(cmd.target); } },
      }));