Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const waitFor = function(search :function, callback :function, interval = 500) :void {
- const checkLoop = setInterval(function () {
- let element = search();
- if (typeof element === 'undefined' || element === null) {
- return;
- }
- clearInterval(checkLoop);
- callback(element);
- }, interval);
- };
- export const waitForElement = function(selector :string, callback :function, interval = 500) :void {
- waitFor(function(){ return document.querySelector(selector); }, callback, interval);
- };
- export const waitForElements = function(selector :string, callback :function, interval = 500) :void {
- waitFor(function(){ return document.querySelectorAll(selector); }, callback, interval);
- };
Add Comment
Please, Sign In to add comment