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

    Function createBatchingHttpBridge

    • createBatchingHttpBridge — coalescing fetch-based transport plugin.

      Same per-dispatch call shape and backend options as createHttpBridge (CSRF, retry, timeout, session-expiry are all reused via the same postCommand/httpClient path), but every command dispatched within the batching window is queued and sent as ONE POST:

      { commands: [{ id, command, target, payload }, ...] }

      matched back against:

      { results: [{ id, ok, state, error }, ...] }

      Each queued command's own dispatch promise resolves independently — a caller dispatches exactly as it would against createHttpBridge; the coalescing is invisible to the call site.

      Parameters

      Returns AsyncPlugin

      const bus = createAsyncCommandBus()
      bus.use(createBatchingHttpBridge({ endpoint: '/api/vc/batch', csrf: true }))
      // two dispatches issued in the same tick → one HTTP round trip:
      bus.dispatch('formSet', { field: 'email' }, { value: 'a@b.com' })
      bus.dispatch('cartAdd', product, { quantity: 2 })