@jswork/next-async-queue

1.0.0 • Public • Published

next-async-queue

Async queue for next.

version license size download

installation

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

apis

api params description
run items Run a list of async functions
repeat fn, count Get a repeat functions
wrap [fn,fn] Wrap an list of functions to runnable

status

status name code description
LOAD load 1 Status when task is running
DONE done 0 Status when all task has done

usage

import NxAsyncQueue from '@jswork/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 } ]

license

Code released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i @jswork/next-async-queue

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

9.44 kB

Total Files

5

Last publish

Collaborators

  • afeiship