Binds a one-time event handler to an operating system event

⚠️ NOTE: Requires an active event loop to process events

  • Registers a one-time event handler that will be automatically removed after being called once.

    Type Parameters

    Parameters

    • name: T

      The name of the event to listen for

    • handlerFunction: (...args: Events[T]) => void | Promise<void>

      The function to call when the event occurs

    • filter: null | (...args: Events[T]) => boolean = null

      Optional function to filter events based on their arguments

    Returns () => void

    A function that can be called to remove the event handler

    events.once('player_join',
    (playerName) => console.log(`First player to join: ${playerName}`)
    );