← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1479162] [NEW] Need a way to batch async requests

 

Public bug reported:

In order to make multiple async calls in javascript, we need to nest
them. This makes the code unreadable at some point. There is a better
way to batch multiple async calls using defer and promises. This patch
provides a way to batch async calls and handle it once ALL async calls
are complete.

Nesting example
-------------------------
  keystoneAPI.getRoles(function(roles) {
    // do something with roles here
    settingsAPI.getSetting('SOME_SETTING', 'default').then(function(settings){
      // do something with settings here
    });
  });

Batch example
----------------------
  var async = {
    keystone: keystoneAPI.getRoles(),
    settings: settingsAPI.getSetting('SOME_SETTING', 'default')
  };
  httpBatch.batch(async).then(function(response) {
    // do something here
  });

** Affects: horizon
     Importance: Medium
     Assignee: Thai Tran (tqtran)
         Status: In Progress

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1479162

Title:
  Need a way to batch async requests

Status in OpenStack Dashboard (Horizon):
  In Progress

Bug description:
  In order to make multiple async calls in javascript, we need to nest
  them. This makes the code unreadable at some point. There is a better
  way to batch multiple async calls using defer and promises. This patch
  provides a way to batch async calls and handle it once ALL async calls
  are complete.

  Nesting example
  -------------------------
    keystoneAPI.getRoles(function(roles) {
      // do something with roles here
      settingsAPI.getSetting('SOME_SETTING', 'default').then(function(settings){
        // do something with settings here
      });
    });

  Batch example
  ----------------------
    var async = {
      keystone: keystoneAPI.getRoles(),
      settings: settingsAPI.getSetting('SOME_SETTING', 'default')
    };
    httpBatch.batch(async).then(function(response) {
      // do something here
    });

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1479162/+subscriptions


Follow ups