Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. /**
  2. * @summary Function that wait for var be ready, and when its ready it will run the callback
  3. * @description Function will be reexecuted on setTimeOut until var is ready
  4. * when var exists the `callback` will be executed
  5. * the function usually runs by passing an global param as `variable`
  6. *
  7. * @param { Function } fnIsTrue - The function that should return an boolean
  8. * @param { Function } callback - The callback function to be executed
  9. */
  10. function waitForTrue (fnIsTrue, callback) {
  11. if (fnIsTrue()) {
  12. callback();
  13. } else {
  14. setTimeout(function() {
  15. waitForTrue(fnIsTrue, callback);
  16. }, 50);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement