ready-promise
v0.0.3
Published
Wait for the resource initialization is complete
Downloads
3
Readme
ready-promise
Wait for the resource initialization is complete.
Installation
$ npm install ready-promise --save
Usage
import readyPromise from 'ready-promise'
const isJsBridgeLoaded = () => window.jsBridge
readyPromise(isJsBridgeLoaded, {
rate: 50,
timeout: 1500
}).then(() => {
console.log('jsBridge loaded')
}).catch(e => {
console.log('jsBridge loaded error or timeout')
})
API
readyPromise(watchFunc[, options])
watchFunc
(Function)To determine whether a variable to be monitored exists or meets the conditions, you need to implement it yourself, returning
true
orfalse
.options
rate
(Number) Unitms
, the frequency of executingwatchFunc
, default50
.timeout
(Number) Unitms
, judge the timeout maximum duration limit, the default1500
.