javascript - Synchronizing Asynchronously made Asynchronous calls -


I'm stumped

Actually, I have an HTTP REST API for which I will use asynchronous I can request to provide and provide callback I also have a web front end which will call this API in arbitrary time on arbitrary times.

The problem is that the API requires 'nons', a number that is more than the last with each request, it is easy to prepare this number in such a way. Ensuring that the request reaches the correct order .. It is not so.

I want a way that I can call only functions and provide callback from my API module. And the modules will handle this before any pre-made calls will be finished before making a new call.

Definitely there is a module that allows one to run with asynchronous function synchronous but I need to know all the functions I had to set a fire before

in the normal API call Are doing this

  // This can be likened to a new request with my existing system, while its first process is in the middle. Api module var agneensifen = function () {var d = new date (); Var seconds = Math.flur (DGetTime (1000/1000)); Var nonce = sec; Return work () {return nonce ++; }} (); Var PrivateAppe = Function (key, secret) {var itself = this; Var api = New API (Key, Incognito, Epilation); // Information about the user self.getInfo = callback (callback) {api.getInfo (callback); }; } // ... bla bla set up path ect. - & gt; Enter server request callback // server module // We create an API instance var API = new private API (key, secret); // After some time we make an API call api.getInfo (function (mistake, data) {if (err) {// handle error} // dosomthing with data}}  

pre- var async = require ('async'); // function passed as a cover for the API module. Exports = function OBJ) {var self = this; var q = async.queue (function (callback) (function, callback) {var args = task.args; args.push (function (error , Data) {task.cb (mistake, data); if (mistake) return callback (mistake); callback ();}) obj [task.func] .apply (obj, args);}, 1); var key Var Object = {Function: Keys} = Object Function (var) = var. I], Argus: Ars, Slice (0, Aug., Long - 1), CB: Arizislis. (Args.length - 1, args.length) [0]}; Q.push (function, function) {if (global .DEBUG) console.log ("[SYNC RRAPPER] To make a wrapped call:", key [i]);})}} var buildPropWrapper = function (i) {(Var, i = 0; I & lt; For the keys). (Come, laz [i], {get: function () {obj [key] i]}, writeable: wrong, enumerable: true}}} length; I ++) {if (typhus (ozzy [arc [i]]) === "function") {buildfucker (i); } Else {buildPropWrapper (i); Basically I can pass it to my existing API object and it will forward all the calls made in this work through the queue because only 1 call has a concurrency in the queue


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -