This file contains hidden or 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
//Check | |
let check = (e, m, t, c) => { //(element, max, timeout, callback) | |
let i = +m, | |
loop = () => { $(e).length ? c() : --i && setTimeout(() => { loop() }, t) } | |
loop() | |
}, | |
//Process | |
myFunc = () => { //Do something } | |
//Usage | |
check("element", 30, 500, myFunc) |
This file contains hidden or 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
//Check | |
let check = (e, m, t, c) => { //(element, max, timeout, callback) | |
let i = +m, | |
loop = () => { | |
if ($(e).length) { | |
console.log(`Atieu: Found ${e}\n==========`) | |
c() | |
} else { | |
if (--i) { | |
console.log(`Atieu: Find ${e} for the ${m - i} times\n==========`) |