createEventBus
In-process event bus used by the cart kernel to broadcast lifecycle events
to UI layers (React store, analytics, tab sync). Delivery is fire-and-forget
via queueMicrotask so that emitting never blocks the caller and handler
failures cannot poison the mutation pipeline.
Signature
function createEventBus(opts: { logger: ILogger }): CartEventBus;Parameters
| Name | Type | Description |
|---|---|---|
opts | { logger: ILogger } |
Returns
A with on (returns dispose) and emit.
Example
const bus = createEventBus({ logger: consoleLogger });
const off = bus.on('cart.created', (e) => console.log('created', e.cart.id));
bus.emit({ type: 'cart.cleared' });
off();Related
RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter
createCart
Builds a cart kernel bound to one adapter. The kernel is the hostfacing surface: it routes typed s to adapter methods, gates mutations against , runs the middle
CreateMockCartAdapterOpts
Options for . All fields are optional; omitting them yields an everythingenabled adapter with zero latency and no injected failures.