@jswork/next-loop-execute

1.0.7 • Public • Published

next-loop-execute

Loop execute for next.

version license size download

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 false;
  },
  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.

Package Sidebar

Install

npm i @jswork/next-loop-execute

Weekly Downloads

1

Version

1.0.7

License

MIT

Unpacked Size

6.29 kB

Total Files

5

Last publish

Collaborators

  • afeiship