Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @summary Function that wait for var be ready, and when its ready it will run the callback
- * @description Function will be reexecuted on setTimeOut until var is ready
- * when var exists the `callback` will be executed
- * the function usually runs by passing an global param as `variable`
- *
- * @param { Function } fnIsTrue - The function that should return an boolean
- * @param { Function } callback - The callback function to be executed
- */
- function waitForTrue (fnIsTrue, callback) {
- if (fnIsTrue()) {
- callback();
- } else {
- setTimeout(function() {
- waitForTrue(fnIsTrue, callback);
- }, 50);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement