supersede — auto-cancel the previous in-flight dispatch for the same key.
Built for rapid-fire reads that can overwrite each other in flight — a
search box re-querying on every keystroke, a filter changing before the
previous fetch lands. Without it, a slow first response can arrive AFTER a
faster second one and clobber it with stale data. With it, the first
dispatch's AbortSignal fires the instant a second dispatch for the same key
starts — createHttpBridge / createBatchingHttpBridge already forward
cmd.signal to fetch(), so the stale request is genuinely cancelled, not
merely ignored once it resolves.
Async bus only — mutates cmd.signal before the rest of the pipeline
runs, which is only meaningful for cancelable async dispatches.
constbus = createAsyncCommandBus(); bus.use(supersede({ actions: ['productSearch'] })); bus.use(createHttpBridge({ endpoint:'/api/vc' })); // three quick productSearch dispatches → only the last one's response is // ever awaited; the first two are aborted mid-flight, not just discarded
supersede — auto-cancel the previous in-flight dispatch for the same key.
Built for rapid-fire reads that can overwrite each other in flight — a search box re-querying on every keystroke, a filter changing before the previous fetch lands. Without it, a slow first response can arrive AFTER a faster second one and clobber it with stale data. With it, the first dispatch's AbortSignal fires the instant a second dispatch for the same key starts —
createHttpBridge/createBatchingHttpBridgealready forwardcmd.signaltofetch(), so the stale request is genuinely cancelled, not merely ignored once it resolves.Async bus only — mutates
cmd.signalbefore the rest of the pipeline runs, which is only meaningful for cancelable async dispatches.