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