A Typescript port of Broadway https://github.com/broadway/broadway
NPM:
npm install hollywood-js
Yarn:
yarn add hollywood-js
import { Domain } from 'hollywood-js'
export class UserWasCreated extends Domain.DomainEvent {
constructor(public uuid: string, public email: string){
super()
}
}
export class User extends Domain.EventSourced {
private uuid: string = "";
private email?: string;
public static create(uuid: string, email: string): User {
const instance = new User(uuid);
instance.raise(new UserWasCreated(uuid, email));
return instance;
}
public getAggregateRootId(): string {
return this.uuid;
}
protected applyUserWasCreated(event: UserWasCreated): void {
this.uuid = event.uuid;
this.email = event.email;
}
}
Look at examples for a better understanding.