import type { BusBuffer } from './command-bus'; import { _BUFFER } from './command-bus'; import { type Signal } from './signal'; export type BufferOptions = { /** * Max commands held per action. Past it the oldest is dropped: its `done` * settles with `buffer:exceeded:queue`. Default: 256, also for NaN. * `Infinity` means no bound, 0 holds nothing. */ maxSize?: number; /** * Max age (ms) a command may wait for its handler. An older one is dropped * (`buffer:timeout:queue`), checked on the next hold of that action and when * its handler registers, so a handler that never arrives cannot pin stale * commands. Default: no limit. */ ttl?: number; /** Called for each command dropped by `maxSize` or `ttl`: one place to observe drops. */ onDrop?: (action: string, dropped: { target: any; payload: any; }) => void; }; /** The object `createBuffer` returns. Pass it to a bus as its `buffer` option. */ export type CommandBuffer = { /** How many commands wait for their handler, all actions together. */ pending: Signal; /** @internal The bus's half: the bus calls it, an app does not. */ readonly [_BUFFER]: BusBuffer; }; /** * createBuffer - hold a command dispatched before its handler, and run it, * in order, when the handler registers. * * @example * const bus = createCommandBus({ buffer: createBuffer({ ttl: 30_000 }) }); * const r = bus.dispatch('cartAdd', item); // before the island hydrates * if (r.value instanceof Accepted) await r.value.done; // the handler's result */ export declare function createBuffer(options?: BufferOptions): CommandBuffer; //# sourceMappingURL=buffer.d.ts.map