ts-event-bus
Version:
Distributed messaging in Typescript
21 lines • 1.12 kB
TypeScript
/**
* A Handler represents a callable that is capable of responding to an event.
* It may be directly provided by the client in the case of same-process usage,
* or provided by the transport in the case of remote usage.
*
* Handlers may be synchronous or asynchronous. Asynchronicity is Promise-based.
*/
export type Handler<RequestData = any, ResponseData = any> = (requestData: RequestData) => ResponseData | Promise<ResponseData>;
/**
* Helper function to call all the handlers registered for a given event and
* map the result of the call to a Promise.
*
* - If no handlers are registered, the Promise is automatically fulfilled.
* - If one handler is registered, a Promise that will resolve with the result
* of the call of that one handler will be returned
* - If more than one handler is registered, a Promise that will resolve when all
* handlers have been successfully called and fulfilled is returned, but the results
* of all these handlers is discarded.
*/
export declare function callHandlers(data: any, handlers: Handler<any, any>[]): Promise<any>;
//# sourceMappingURL=Handler.d.ts.map