0.0.3 • Published 6 years ago
ready-promise v0.0.3
ready-promise 
Wait for the resource initialization is complete.
Installation
$ npm install ready-promise --saveUsage
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
trueorfalse.optionsrate(Number) Unitms, the frequency of executingwatchFunc, default50.timeout(Number) Unitms, judge the timeout maximum duration limit, the default1500.