Smootify.on()
listens to an event; `replay` also calls the handler with the last payload of one that already happened. Returns the unsubscribe.
listens to an event; replay also calls the handler with the last payload of one that already happened. Returns the unsubscribe. New in 2.0.
on<N extends SmootifyEventName | SmootifyShortEventName>( name: N, handler: SmootifyEventHandler<N>, options?: { replay?: boolean }, ): () => voidTypes
SmootifyEventName
export type SmootifyEventName = keyof SmootifyEventMap;SmootifyShortEventName
/** A `smootify:` event by its name alone: `cart_updated`, `wishlist:changed_product`. */
export type SmootifyShortEventName = {
[K in SmootifyEventName]: K extends `smootify:${infer Short}` ? Short : never;
}[SmootifyEventName];SmootifyEventHandler
export type SmootifyEventHandler<N extends SmootifyEventName | SmootifyShortEventName> = (
payload: SmootifyEventMap[FullEventName<N>],
) => void;