Skip to main content

Event <Args, Scope>

Hierarchy

Index

Constructors

constructor

  • new Event<Args, Scope>(name: string): Event<Args, Scope>
  • Type parameters

    • Args: unknown[]
    • Scope: string = string

Properties

listeners

listeners: Map<* | Scope, Set<Listener<Args, void>>> = ...

name

name: string

Methods

clearListeners

  • clearListeners(scope?: Scope): this
  • Remove all listeners from the event.

emit

  • emit(args: Args, scope?: Scope): void
  • Synchronously execute listeners with the defined arguments.

getListeners

  • getListeners(scope?: Scope): Set<Listener<Args, void>>
  • Return a set of listeners for a specific event scope.

getScopes

  • getScopes(): (* | Scope)[]
  • Return a list of all scopes with listeners.

listen

  • Register a listener to the event.

once

  • Register a listener to the event that only triggers once.

unlisten

  • unlisten(listener: Listener<Args, void>, scope?: Scope): this
  • Remove a listener from the event.