/queue-request

Primary LanguageTypeScriptMIT LicenseMIT

queue-request

queue-request - library to collect duplicated async task in 1 queve, make 1 operation and return same Promise to every request

Problem and solution

Problem

Problem schema

Possible solution

Solution schema

Install

$ yarn add queue-request

Usage

const queueRequest = require('queue-request');


//One place in code
queueRequest({request: APIRequest, params: 1, processDelay: 90});
//Another place in code
queueRequest({request: APIRequest, params: 2, processDelay: 90});
//Another place in code
queueRequest({request: APIRequest, params: 3, processDelay: 90});
//Another place in code
queueRequest({request: APIRequest, params: 4, processDelay: 90});

/**
 * If code was called in margin of processDelay
 * in callstack it will call API only once
 * And resolve to same code
 */

Publish

$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags

License

MIT ©