Poll: {
    createEventPoll: (<TReturnType>(callBack: (() => Promise<TReturnType>), requestIntervalInMilliseconds: number, hasToStopOnError??: boolean) => EventPoll<TReturnType>);
    SyncPoll: (<TReturnType>(pollingFunction: (() => TReturnType | Promise<TReturnType>), options?: SyncPollInputOptions) => {
        waitUntil: ((condition: ((data: TReturnType) => boolean)) => Promise<TReturnType>);
    });
} = ...

Type declaration

  • createEventPoll: (<TReturnType>(callBack: (() => Promise<TReturnType>), requestIntervalInMilliseconds: number, hasToStopOnError??: boolean) => EventPoll<TReturnType>)
      • <TReturnType>(callBack, requestIntervalInMilliseconds, hasToStopOnError?): EventPoll<TReturnType>
      • Creates an event poll that performs a callback function repeatedly at a specified interval. This method is useful to create an event poll in a more readable way.

        Type Parameters

        • TReturnType

        Parameters

        • callBack: (() => Promise<TReturnType>)

          The callback function to be executed on each interval. It should return a Promise.

        • requestIntervalInMilliseconds: number

          The interval in milliseconds at which the callback function will be executed.

        • OptionalhasToStopOnError: boolean = true

          Optional parameter to specify whether the poll should stop on error. Default is true.

        Returns EventPoll<TReturnType>

        • The created event poll instance.
  • SyncPoll: (<TReturnType>(pollingFunction: (() => TReturnType | Promise<TReturnType>), options?: SyncPollInputOptions) => {
        waitUntil: ((condition: ((data: TReturnType) => boolean)) => Promise<TReturnType>);
    })
      • <TReturnType>(pollingFunction, options?): {
            waitUntil: ((condition: ((data: TReturnType) => boolean)) => Promise<TReturnType>);
        }
      • Poll until the condition is met.

        @note: Be careful!, this function is synchronous and will block the thread until the condition is met. Thus mean it can run forever if the condition is never met. To avoid infinite loop, you can use the options.maximumIterations parameter.

        Type Parameters

        • TReturnType

        Parameters

        Returns {
            waitUntil: ((condition: ((data: TReturnType) => boolean)) => Promise<TReturnType>);
        }

        An object with a waitUntil method. It blocks execution until the condition is met. When the condition is met, it returns the result of the poll.

        It can be used to wait until:
        - A balance is updated after a transaction is sent
        - A transaction is mined
        - A block is mined
        ...

        type. If not specified, the default values are used. In particular: requestIntervalInMilliseconds is 1000, maximumIterations is not specified and maximumWaitingTimeInMilliseconds is not specified.