Μετάβαση στο περιεχόμενο

createCqrs

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

createCqrs(options?): Cqrs

Defined in: packages/cqrs/src/create-cqrs.ts:76

Creates the command, query and event buses with no container: the application builds its handlers with new and registers them. Global behaviors are built here, so one whose required dependency is missing fails at once.

CqrsOptions = {}

Cqrs

TypeError on two instances of one behavior class.

const cqrs = createCqrs({
behaviors: [new AuditBehavior(sink)],
globalBehaviors: { before: [LoggingBehavior] },
sources: { tenantId: tenantSource, correlationId: correlationSource },
});
cqrs.register(new CreateUserHandler(users, cqrs.eventBus), new GetUserHandler(users));
const id = await cqrs.commandBus.execute(new CreateUserCommand('Ann'));
await cqrs.close();