1.0.2 • Published 4 years ago

@feizheng/next-async-queue v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

next-async-queue

Async queue for next.

installation

npm install -S @feizheng/next-async-queue

apis

apiparamsdescription
runitemsRun a list of async functions
repeatfn, countGet a repeat functions
wrapfn,fnWrap an list of functions to runnable

status

statusnamecodedescription
LOADload1Status when task is running
DONEdone0Status when all task has done

usage

import NxAsyncQueue from '@feizheng/next-async-queue';

var fn1 = function(next){
  setTimeout(function(){
    console.log(123,'1s');
    next({ result: 1});
  },1000);
};

var fn2 = function(next){
  setTimeout(function(){
    console.log(456,'2s');
    next({ result: 2});
  },1000);
};

var fn3 = function(next){
  setTimeout(function(){
    console.log(789,'3s');
    next({ result: 3});
  },1000);
};

NxAsyncQueue.run(fn1, fn2, fn3).then((res) => {
  console.log(res);
});

// results:
// 123 1s
// 456 2s
// 789 3s
// [ { result: 1 }, { result: 2 }, { result: 3 } ]
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago