Web3JS Online
Viem Online
Webhooks, Alerts, and a simple API.
The pollTillDefinedAndReturnIntervalId function is a utility method provided by the web3.utils module that repeatedly calls an asynchronous function with a given interval until the result of the function is defined (not undefined or null), or until a timeout is reached. It returns a tuple of two values: a Promise
The function takes two parameters: func and interval. The func parameter is an asynchronous function of type AsyncFunction
The interval parameter is a number that represents the interval in milliseconds between each call to the func function.
The pollTillDefinedAndReturnIntervalId function returns a tuple of two values:
Here's an example of how the pollTillDefinedAndReturnIntervalId function can be used:
In this example, the pollTillDefinedAndReturnIntervalId function is called with an asynchronous function that performs some asynchronous operation and returns the result. The interval parameter is set to 1000, which means that the function will be called every 1000 milliseconds until the result is defined. Once the result is defined, the pollTillDefinedAndReturnIntervalId function resolves the resultPromise to the result and returns the intervalId. The intervalId can be used to stop the polling using the clearInterval method.