How to use the @node-ts/bus-workflow.Handles function in @node-ts/bus-workflow

To help you get started, we’ve selected a few @node-ts/bus-workflow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-ts / bus-starter / src / workflows / siren-test-workflow.ts View on Github external
sirenId
    )
    await this.bus.send(emailMaintenanceTeam)
    return {}
  }

  @Handles(
    SirenTestPassed,
    event => event.sirenId,
    'sirenId'
  )
  async handlesSirenTestPassed (_: SirenTestPassed): Promise> {
    return this.complete()
  }

  @Handles(
    MaintenanceTeamEmailed,
    event => event.sirenId,
    'sirenId'
  )
  async handlesMaintenanceTeamEmailed (_: MaintenanceTeamEmailed): Promise> {
    return this.complete({
      maintenanceEmailSent: true
    })
  }

}
github node-ts / bus-starter / src / workflows / siren-test-workflow.ts View on Github external
@Handles(
    SirenTestFailed,
    event => event.sirenId,
    'sirenId'
  )
  async handlesSirenTestFailed ({ sirenId }: SirenTestFailed): Promise> {
    const emailMaintenanceTeam = new EmailMaintenanceTeam(
      'A siren has failed its test and requires maintenance',
      sirenId
    )
    await this.bus.send(emailMaintenanceTeam)
    return {}
  }

  @Handles(
    SirenTestPassed,
    event => event.sirenId,
    'sirenId'
  )
  async handlesSirenTestPassed (_: SirenTestPassed): Promise> {
    return this.complete()
  }

  @Handles(
    MaintenanceTeamEmailed,
    event => event.sirenId,
    'sirenId'
  )
  async handlesMaintenanceTeamEmailed (_: MaintenanceTeamEmailed): Promise> {
    return this.complete({
      maintenanceEmailSent: true
github node-ts / bus-starter / src / workflows / siren-test-workflow.ts View on Github external
export class SirenTestWorkflow extends Workflow {

  constructor (
    @inject(BUS_SYMBOLS.Bus) private readonly bus: Bus
  ) {
    super()
  }

  @StartedBy(SirenTestStarted)
  handlesSirenTestStarted ({ sirenId }: SirenTestStarted): Partial {
    return {
      sirenId
    }
  }

  @Handles(
    SirenTestFailed,
    event => event.sirenId,
    'sirenId'
  )
  async handlesSirenTestFailed ({ sirenId }: SirenTestFailed): Promise> {
    const emailMaintenanceTeam = new EmailMaintenanceTeam(
      'A siren has failed its test and requires maintenance',
      sirenId
    )
    await this.bus.send(emailMaintenanceTeam)
    return {}
  }

  @Handles(
    SirenTestPassed,
    event => event.sirenId,