Wait for the resource initialization is complete.
$ npm install ready-promise --save
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')
})
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
.