CartEventHandler

cart · /core·type

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

@nordcom/commerce-cart
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);
};

RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter

Sourceevents.ts:49Edit the JSDoc directly

On this page