import { Message, MessageAttributes } from '@node-ts/bus-messages'; import { ClassConstructor } from '../util'; import { CustomHandler } from './custom-handler'; /** * Defines the types of messages that the bus can handle */ export type MessageBase = Message | object; /** * Implemented by a class to indicate it acts as a handler for a given message */ export interface Handler { /** * The type of message the class handles */ messageType: ClassConstructor; /** * A function that is called each time a message of `messageType` is received * @param message The message read from the bus * @param attributes Attributes of the message read from the bus */ handle(message: TMessage, attributes: TMessageAttributes): void | Promise; } export type FunctionHandler = (message: TMessage, attributes: TMessageAttributes) => void | Promise; export type HandlerDefinition = FunctionHandler | ClassConstructor> | ClassConstructor>; /** * A naive but best guess effort into if a handler is class based and should be resolved from a container */ export declare const isClassHandler: (handler: HandlerDefinition) => any;