Class EventPoller

The EventPoller class provides a convenient way to poll events from the Massa network.

Hierarchy

  • EventEmitter
    • EventPoller

Constructors

  • Constructor of the EventPoller object.

    Parameters

    • provider: Provider

      The provider to use for polling.

    • eventsFilter: EventFilter

      The filter to use for the events.

    • pollIntervalMs: number

      The interval in milliseconds to poll for events.

    Returns EventPoller

Properties

eventsFilter: EventFilter

The filter to use for the events.

intervalId: Timeout
lastSlot: Slot
pollIntervalMs: number

The interval in milliseconds to poll for events.

provider: Provider

The provider to use for polling.

prefixed: string | boolean

Methods

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Rest ...args: any[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Starts polling for events and returns the stopPolling function.

    Parameters

    • provider: Provider

      The provider to use for polling.

    • eventsFilter: EventFilter

      The filter to use for the events.

    • Optional onData: ((data) => void)

      The callback function to call when new events are found.

        • (data): void
        • Parameters

          Returns void

    • Optional onError: ((err) => void)

      The callback function to call when an error occurs.

        • (err): void
        • Parameters

          • err: Error

          Returns void

    • pollIntervalMs: number = DEFAULT_POLL_INTERVAL_MS

      The interval in milliseconds to poll for events. Default is 1000Ms.

    Returns {
        stopPolling: (() => void);
    }

    An object containing the stopPolling function.

    • stopPolling: (() => void)
        • (): void
        • Returns void