wait-for-any
v1.0.2
Published
Wait until the condition is met. Used to detect dynamically injected variables, such as `window.ethereum`
Downloads
7
Readme
wait-for-any
Wait until the condition is met. Used to detect dynamically injected variables, such as window.ethereum
Install
npm install wait-for-any
Example
Wait until ethereum injection
import waitFor from 'wait-for-any'
const ethereum = await waitFor(() => window.ethereum)
console.log(ethereum === window.ethereum) // true
Browser
<script src="dist/index.js">
<script>
window.waitFor()
</script>
Parameter
waitFor(condition, [options])
condition
: function - if the return value is not null, the condition is trueoptions
timeout
: number - maximum detection time, default 5000 msstep
: number - interval between each detect, default 500 ms