Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AutomationEvent

A base class for events passed to automations. Every automation event provides the eventType string field that allows for identification of the event type inside the automation.

Hierarchy

Index

Properties

Methods

Properties

Readonly Abstract eventType

eventType: string

A type of this event. Used for routing and filtering of events.

example

Can be used to identify the type of the event in automation:

async handleEvent(event: TimerEvent) {
  if(isTimerEvent(event))
    console.log(`${this.name} was triggered!`);
}

Methods

handleAs

  • handleAs<T>(eventClass: Constructor<T>): T
  • Force-cast the event as specified type.

    example

    Can be used to identify the type of the event in an automation:

    async handleEvent(event: AutomationEvent) {
      try {
        const timerEvent = event.handleAs(TimerEvent);
      } catch (e) {
        // ...
      }
    }
    throws

    Throws an error if the cast failed.

    Type parameters

    Parameters

    • eventClass: Constructor<T>

      An AutomationEvent subclass to cast this event to.

    Returns T

    An event casted to a type specified in eventClass argument.

Generated using TypeDoc