vlocode-project - v1.40.0-beta-4
    Preparing search index...

    Class EventEmitter<T>

    Lightweight event emitter implementation

    const emitter = new EventEmitter<{ hello: string }>();
    emitter.on('hello', (params) => console.log('Hello', params));
    emitter.fire({ hello: 'world' }); // prints "Hello world"
    emitter.fire({ hello: 'again' }); // prints "Hello again"
    emitter.dispose();
    emitter.fire({ hello: 'again' }); // does nothing as emitter is disposed

    Type Parameters

    • T
    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    disposed: boolean = false
    listeners: Record<string, { listener: (e: T) => any; thisArg?: any }> = {}

    Accessors

    Methods

    • Fire an event to all registered listeners with the provided data

      Parameters

      • data: T

        Data to pass to the event listeners

      • Optionaloptions: { throwErrors?: boolean }

        Options for firing the event

      Returns void

      void

    • Register a listener that listens for events being fired by the emitter

      Parameters

      • listener: (e: T) => any

        Listener to register

      • OptionalthisArg: any

        Optional thisArg to use when calling the listener

      Returns () => void

      A function that can be called to unregister the listener