Skip to content

Instantly share code, notes, and snippets.

@elad-yosifon
Created June 11, 2019 09:39
Show Gist options
  • Save elad-yosifon/ccfcc19b026fa3cc076d00edc3d2a299 to your computer and use it in GitHub Desktop.
Save elad-yosifon/ccfcc19b026fa3cc076d00edc3d2a299 to your computer and use it in GitHub Desktop.
/**
*
* @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