Web3JS Online
Viem Online
Webhooks, Alerts, and a simple API.
The rejectIfConditionAtInterval function is a utility method provided by the web3.utils module that sets an interval that repeatedly executes a given condition function with a specified interval between each call. If the condition is met, the interval is cleared and a Promise that rejects with the returned value is returned.
The function takes two parameters:
Here's an example of how the rejectIfConditionAtInterval function can be used:
In this example, the rejectIfConditionAtInterval function is called with a condition function that checks the current user agent every second. If the user agent changes, the interval is cleared and a Promise that rejects with the new user agent is returned. The console.log statement logs the interval ID and the Promise to the console. After 5 seconds, the interval is cleared using the clearInterval function.