Skip to content

@ue-too/board / createHandlerChain

Function: createHandlerChain()

createHandlerChain<T, Args>(...handlers): Handler<T, Args>

Defined in: packages/board/src/utils/handler-pipeline.ts:31

Type Parameters

T

T

Args

Args extends any[]

Parameters

handlers

Array of handler functions to be chained

Handler<T, Args>[] | [Handler<T, Args>[]]

Returns

Handler<T, Args>

A single handler function that executes all handlers in sequence

Description

Creates a handler chain from an array of handlers.

Use it like this:

typescript
const handlerChain = createHandlerChain(handler1, handler2, handler3);

or like this:

typescript
const handlers = [handler1, handler2, handler3];
const handlerChain = createHandlerChain(handlers);

The function signature of all the handlers must be the same. (if they're not, you need to explicitly specify the type for the handler chain)