Documentation
    Preparing search index...

    Typed event emitter that works both for Web and React Native.

    interface TypedEventEmitter<T extends EventMap> {
        addListener<K extends string>(
            type: K,
            listener: EventReceiver<T[K]>,
        ): this;
        emit<K extends string>(type: K, params: T[K]): boolean;
        getMaxListeners(): number;
        listenerCount<K extends string>(type: K): number;
        removeAllListeners(type?: string): this;
        removeListener<K extends string>(
            type: K,
            listener: EventReceiver<T[K]>,
        ): this;
        setMaxListeners(n: number): this;
    }

    Type Parameters

    Index

    Methods

    • Synchronously calls each of the listeners registered for the given event type, in the order they were registered, passing the supplied arguments.

      Type Parameters

      • K extends string

      Parameters

      • type: K

        A case-sensitive string representing the event type.

      • params: T[K]

        Optional parameters.

      Returns boolean

      Whether the event had listeners.

    • Returns the number of listeners for the event of the given type.

      Type Parameters

      • K extends string

      Parameters

      • type: K

        A case-sensitive string representing the event type.

      Returns number

      The number of listeners.

    • By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. Use this function to modify the default threshold.

      Parameters

      • n: number

        Number of listeners before printing a warning. The value can be set toInfinity (or 0) to indicate an unlimited number of listeners.

      Returns this

      A reference to the EventEmitter.