@jswork/next-loop-execute
v1.0.8
Published
Loop execute for next.
Downloads
96
Readme
next-loop-execute
Loop execute for next.
installation
npm install -S @jswork/next-loop-execute
usage
import '@jswork/next-loop-execute';
const fetchApi = function ({ count }) {
return fetch('https://api.github.com/users/afeiship').then(res=>res.json());
}
// loop 3 times:
nx.loopExecute({
interval: 200,
timeout: 10 * 1000,
interrupt: (res)=>{
return manualInterruptFlag;
},
callback: (data) => {
console.log(data);
return fetch('https://api.github.com/users/afeiship').then((res) => res.json());
},
done: (res) => {
return res.data.status === 'FINISHED';
}
}).then((res) => {
console.log('DONE:', res);
})
license
Code released under the MIT license.