Created
June 11, 2019 09:39
-
-
Save elad-yosifon/ccfcc19b026fa3cc076d00edc3d2a299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @param {function():*} action | |
* @param {function(*)} callback | |
*/ | |
window.watch = function (action, callback) { | |
var watcherId = setInterval(function () { | |
var element = action(); | |
if (element) { | |
clearInterval(watcherId); | |
callback(element); | |
} | |
}, 10); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment