s
s
snc
Search…
forever
snc.forever(callback(repeat, end), callback_end(data))
Loops syncronous forever.
Alternative name: fe.
1
snc.forever((repeat, end) => {
2
console.log(`Hi!`)
3
setTimeout(repeat, 3000)
4
});
Copied!
1
-> Hi! // Wait 3 seconds;
2
-> Hi! // Wait 3 seconds;
3
-> ...
Copied!
Breaking forever loop.
1
var i = 0;
2
snc.fe((repeat, end) => {
3
console.log(`loop: ${i}`)
4
if (i>=3) end(`Now Break!!`)
5
else {
6
i++;
7
setTimeout(repeat, 3000)
8
}
9
}, data => {
10
console.log(`Response: ${data}`)
11
});
Copied!
1
-> loop: 0 // Wait 3 seconds;
2
-> loop: 1 // Wait 3 seconds;
3
-> loop: 2 // Wait 3 seconds;
4
-> loop: 3 // Wait 3 seconds;
5
-> Response: Now Break!!
Copied!
Copy link