Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DyalApp

A DYAL app

example
const app = createApp(dependencies);
const commandBus: CommandBus = createCommandBus();
commandBus.register('CountCommand', countCommandHandler);
app.on('command').use(commandBus.middleware);

export interface CountCommandResult {
total: number;
}

const countCommand: CountCommand = {
type: 'command',
name: 'CountCommand',
payload: {
count: 5,
},
};

const result = await app.execute<CountCommandResult>(countCommand);

Hierarchy

  • DyalApp

Index

Methods

  • execute<R>(useCase: UseCase): Promise<R>
  • example
    const app = createApp(dependencies);
    const commandBus: CommandBus = createCommandBus();
    commandBus.register('CountCommand', countCommandHandler);
    app.on('command').use(commandBus.middleware);

    export interface CountCommandResult {
    total: number;
    }

    const countCommand: CountCommand = {
    type: 'command',
    name: 'CountCommand',
    payload: {
    count: 5,
    },
    };

    const result = await app.execute<CountCommandResult>(countCommand);

    Type parameters

    • R

    Parameters

    • useCase: UseCase

      The useCase to execute.

    Returns Promise<R>

    R

  • example
    app.on('command').use(commandHandlerMiddleware);
    

    Parameters

    • target: UseCaseType

      It's the kind of use case your middleware will be called for. Can be query, command or all

    Returns { use: any }

    • use:function
      • example
        app.on('all').use(middleware);
        

        Parameters

        • middleware: Middleware

          middleware to add to the app stack

        Returns void

        void

  • example
    app.use(middleware);
    

    Parameters

    • middleware: Middleware

      middleware to add to the app stack

    Returns void

    void

Generated using TypeDoc