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

    Function useCommandState

    • useCommandState - create reactive state that updates via commands.

      Auto-cleanup on Vue component unmount or scope disposal.

      Type Parameters

      • T

      Parameters

      Returns { state: Signal<T>; dispose: () => void }

      // Immediate mode (default):
      const { state } = useCommandState([], { cartAdd: (s, cmd) => [...s, cmd.target] });
      // Coalesced mode — batch writes for v-for lists:
      const { state } = useCommandState([], { cartAdd: (s, cmd) => [...s, cmd.target] }, { coalesce: true });