CartEventHandler
Callback signature for a subscriber to a specific variant.
The generic narrows the event parameter to exactly the variant identified
by E, so handlers receive strongly-typed payloads without casting.
Definition
type CartEventHandler = (event: Extract<CartEvent, { type: E }>) => void | Promise<void>;(event: Extract<CartEvent, { type: E }>) => void | Promise<void>
Example
const onCreated: CartEventHandler<'cart.created'> = (event) => {
console.log('new cart', event.cart.id);
};Related
RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter
CartEventBus
Inprocess pub/sub channel through which the kernel broadcasts cart lifecycle events. Returned by ; passed to internally and exposed on the returned via its on m
CartEventType
Union of the string literal type discriminants for every variant. Use as a constraint when narrowing to a specific event type or when parameterizing .