Skip to content

Commit

Permalink
Merge branch 'underfisk/cqrs-docs' of https://github.com/underfisk/cqrs
Browse files Browse the repository at this point in the history
… into underfisk-underfisk/cqrs-docs
  • Loading branch information
kamilmysliwiec committed Aug 20, 2020
2 parents 5ea06ab + 1a06e4c commit a22fd01
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/decorators/command-handler.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import 'reflect-metadata';
import { ICommand } from '../index';
import { COMMAND_HANDLER_METADATA } from './constants';

/**
* CommandHandler handles actions dispatched on `CommandBus`
* @param command `ICommand`
* @see https://docs.nestjs.com/recipes/cqrs#commands
*/
export const CommandHandler = (command: ICommand): ClassDecorator => {
return (target: object) => {
Reflect.defineMetadata(COMMAND_HANDLER_METADATA, command, target);
Expand Down
5 changes: 5 additions & 0 deletions src/decorators/events-handler.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import 'reflect-metadata';
import { IEvent } from '../index';
import { EVENTS_HANDLER_METADATA } from './constants';

/**
* EventHandler handle dispatched on `EventPublisher`
* @param events List of `IEvent`
* @see https://docs.nestjs.com/recipes/cqrs#events
*/
export const EventsHandler = (...events: IEvent[]): ClassDecorator => {
return (target: object) => {
Reflect.defineMetadata(EVENTS_HANDLER_METADATA, events, target);
Expand Down
4 changes: 4 additions & 0 deletions src/decorators/query-handler.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import 'reflect-metadata';
import { IQuery } from '../interfaces';
import { QUERY_HANDLER_METADATA } from './constants';

/**
* QueryHandler's are responsive for the queries dispatch in `QueryBus` and usually used to `reads`
* @see https://docs.nestjs.com/recipes/cqrs#queries
*/
export const QueryHandler = (query: IQuery): ClassDecorator => {
return (target: object) => {
Reflect.defineMetadata(QUERY_HANDLER_METADATA, query, target);
Expand Down
4 changes: 4 additions & 0 deletions src/decorators/saga.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'reflect-metadata';
import { SAGA_METADATA } from './constants';

/**
* Sagas may listen and react for N events
* @see https://docs.nestjs.com/recipes/cqrs#sagas
*/
export const Saga = (): PropertyDecorator => {
return (target: object, propertyKey: string | symbol) => {
const properties =
Expand Down

0 comments on commit a22fd01

Please sign in to comment.