All Projects → subbu963 → buzy

subbu963 / buzy

Licence: MIT license
Async queue manager for node and browser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to buzy

Mappersmith
is a lightweight rest client for node.js and the browser
Stars: ✭ 282 (+1126.09%)
Mutual labels:  promise, ajax
Atomic
A tiny, Promise-based vanilla JS Ajax/HTTP plugin with great browser support.
Stars: ✭ 526 (+2186.96%)
Mutual labels:  promise, ajax
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (-8.7%)
Mutual labels:  promise, promise-library
Rapid.js
An ORM-like Interface and a Router For Your API Requests
Stars: ✭ 700 (+2943.48%)
Mutual labels:  promise, ajax
Wretch
A tiny wrapper built around fetch with an intuitive syntax. 🍬
Stars: ✭ 2,285 (+9834.78%)
Mutual labels:  promise, ajax
alls
Just another library with the sole purpose of waiting till all promises to complete. Nothing more, Nothing less.
Stars: ✭ 13 (-43.48%)
Mutual labels:  promise, promise-library
Promise Fun
Promise packages, patterns, chat, and tutorials
Stars: ✭ 3,779 (+16330.43%)
Mutual labels:  promise, promise-library
Rext
🎈A lightweight (< 5kb gzipped) and Promise-supported HTTP request library, for all browsers.
Stars: ✭ 14 (-39.13%)
Mutual labels:  promise, ajax
Jdeferred
Java Deferred/Promise library similar to JQuery.
Stars: ✭ 1,483 (+6347.83%)
Mutual labels:  promise, promise-library
promised-hooks
Middleware utility for your Promises
Stars: ✭ 25 (+8.7%)
Mutual labels:  promise, promise-library
nancy
How JavaScript Promise Works
Stars: ✭ 26 (+13.04%)
Mutual labels:  promise, promise-library
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-13.04%)
Mutual labels:  promise
iworker
Promise-based wrapper for worker_threads
Stars: ✭ 18 (-21.74%)
Mutual labels:  promise
advanced-web-developer-bootcamp-notes-examples-and-exercises
Examples and Exercises compiled. From the awesome Advanced Web Developer Bootcamp
Stars: ✭ 24 (+4.35%)
Mutual labels:  ajax
Promise.allSettled
ES Proposal spec-compliant shim for Promise.allSettled
Stars: ✭ 93 (+304.35%)
Mutual labels:  promise
sozlukus.com
sozlukus.com source code
Stars: ✭ 11 (-52.17%)
Mutual labels:  ajax
microteam
小团队管理 是一款开源的微信小程序,主要用于日常的团队管理
Stars: ✭ 40 (+73.91%)
Mutual labels:  promise
Flask-Plotly
Interactive Web Apps and Dashboards
Stars: ✭ 79 (+243.48%)
Mutual labels:  ajax
ajax
Just another AJAX requests helper
Stars: ✭ 27 (+17.39%)
Mutual labels:  ajax
hangman-game
A responsive hangman game built with vanilla javascript, html, and css. Animated with GSAP and canvas animations.
Stars: ✭ 22 (-4.35%)
Mutual labels:  promise

buzy

Promise based async queue manager for node and browser.

Buzy is a blackbox into which you push promises and at each point in time you can know if any of the promises are still in pending state(busy state). Optionally you can subscribe for the event bus which will let you know when there is change in the blackbox state

Its particularly useful where you want to know if your system is busy with async activities like ajax calls etc. You can push promises in to the queue and buzy will do the job of letting you know when the state of the system changes. Use cases can be:

  1. Show loaders on ajax calls
  2. Check if any of your tasks are pending before closing the browser and similar others

Installation

$ npm install buzy

Syntax

new Buzy(subscribers, buzies);
  • subscribers - array of functions which will be called upon the change when there is a state change or when a promise is resolved/reject(this wont be triggered for buzies dependent on other buzies)
  • buzies - array of buzies to subscribe on to

Subscribers will be called with the following message data structure

{
    code: number, // 0 - STATE change, 1 - RESOLVE, 2 - REJECT
    busy: true/false,
    promise: promise, //promise which is last resolved/rejected
    value: value, // value of the resolution
    error: error // error of the rejection
}

New promises can be added with:

buzy.addPromise(promise) //single promise
buzy.addPromises(promises) //array of promises

New subscribers can be added with:

buzy.addSubscriber(subscriber) //single subscriber
buzy.addSubscribers(subscribers) //array of subscribers

New buzies can be added with:

buzy.addBuzy(buzy) //single buzy
buzy.addBuzies(buzies)//array of buzies

To check if buzy is busy or not:

buzy.isBusy() //true or false

Examples

import Buzy from 'buzy';

const buzy1 = new Buzy([function(message) {
  console.log(message);
   /*
      Prints the following:
      {
          code: 0,
          busy: true
      }
      And after 1000 milliseconds
      {
          code: 1,
          promise: Promise{'done'},
          value: 'done'
      }
      And then
      {
          code: 0,
          busy: false
      }
    */
}]);
const buzy2 = new Buzy([function(message) {
  console.log(message);
  /*
    Prints the following:
    {
        code: 0,
        busy: true
    }
    And after fetch is complete
    {
        code: 1 or 2 based on fetch result,
        promise: Promise{res from fetch},
        value: value or error: error based fetch result
    }
    And then after buzy1 is done with all the tasks
    {
        code: 0,
        busy: false
    }
  */
}], [buzy1]);

buzy1.addPromise(new Promise(function(resolve, reject) {
  setTimeout(function() {
    resolve('done');
  }, 1000);
}))
buzy2.addPromise(fetch('http://someurl'));

Check Buzy.test.js for more exmaples

To do

  1. Cancellation of requests
  2. Removal of subscribers/buzies
  3. You tell me!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].