Skip to main content

OnEvent

Callable

  • OnEvent(ofType: AbstractConstructable<Event<unknown>>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void

  • An @OnEvent is a method decorator to listen to an event.

    Octo narrates everything it does as Events. Subscribing is how you add logging, reporting, or notifications without changing the framework. A handler receives every event that is an instance of the given type, so listening to a base class such as TransactionEvent catches all of its subclasses.

    @example
    // Async handler.
    @OnEvent(MyEvent)
    async onEvent(event: MyEvent): Promise<void> { ... }

    // Sync handler.
    @OnEvent(MyEvent)
    onEvent(event: MyEvent): void { ... }
    @group

    Decorators


    Parameters

    • ofType: AbstractConstructable<Event<unknown>>

      The type of event being listened to.

    Returns (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void

    The decorated method.

      • (target: any, propertyKey: string, descriptor: PropertyDescriptor): void
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void