atvik
    Preparing search index...

    Interface SubscriptionFunctions<This, Args>

    Functions used to subscribe and unsubscribe to an event.

    interface SubscriptionFunctions<This, Args extends unknown[] = []> {
        "[asyncIterator]"(): EventIterator<Args>;
        filter(
            filter: (this: This, ...args: Args) => boolean | Promise<boolean>,
        ): Subscribable<This, Args>;
        iterator(options?: EventIteratorOptions): EventIterator<Args>;
        map<NewArgs extends [] | [unknown, ...unknown[]]>(
            mapper: (this: This, ...args: Args) => NewArgs | Promise<NewArgs>,
        ): Subscribable<This, NewArgs>;
        once(options?: OnceOptions): Promise<Args>;
        subscribe(
            listener: Listener<This, Args>,
            options?: SubscribeOptions,
        ): SubscriptionHandle;
        unsubscribe(listener: Listener<This, Args>): void;
        withThis<NewThis>(newThis: NewThis): Subscribable<NewThis, Args>;
    }

    Type Parameters

    • This
    • Args extends unknown[] = []

    Hierarchy (View Summary)

    Implemented by

    Index
    • Create a subscribable that changes the arguments of events before listeners receive them. The mapper returns the new arguments as an array, or a promise of the array:

      const doubled = subscribable.map(n => [ n * 2 ]);
      

      Type Parameters

      • NewArgs extends [] | [unknown, ...unknown[]]

      Parameters

      Returns Subscribable<This, NewArgs>

      mapped Subscribable

    • Get a promise that will resolve the first time this event is fired after this call.

      Parameters

      • Optionaloptions: OnceOptions

        options, such as a signal that stops the wait

      Returns Promise<Args>

      promise that resolves the next time the event is fired