deferred

Async waterfall equivalent with Q

岁酱吖の 提交于 2019-12-10 19:27:53
问题 I've got a single page which is an account settings page. In it, I allow my users to update their avatar (if they've attached an image), change their email (if it has been changed from the original), and change their name and password. Right now, I'm using async's waterfall method, but am swapping out async for Q since I prefer the syntax (and api). I'm wondering if this is the way that I should be using Q in replacement of async's waterfall. I'm doing something like this: exports

Deferred Rendering with OpenGL, experiencing heavy pixelization near lit boundaries on surfaces

∥☆過路亽.° 提交于 2019-12-10 10:26:12
问题 Problem Explaination I am currently implementing point lights for a deferred renderer and am having trouble determining where a the heavy pixelization/triangulation that is only noticeable near the borders of lights is coming from. The problem appears to be caused by loss of precision somewhere, but I have been unable to track down the precise source. Normals are an obvious possibility, but I have a classmate who is using directx and is handling his normals in a similar manner with no issues.

How can I return an array of promises in a then statement

我怕爱的太早我们不能终老 提交于 2019-12-10 10:15:44
问题 So for the past few hours I've been looking into async stuff and using promises. I'm using the testing framework protractor, and theres a few async things I'm having trouble with. In this save function, I call cm.org1.all() asynchronously, and use then to get the response. I loop over the response, and I need call getNewElement() to each element in the response, which also has an async call in it, so each returns a promise. So I have this array of promises, but I don't know how to return it.

Handling different success and fail states for multiple ajax call using deferred objects in jQuery

不问归期 提交于 2019-12-10 03:52:30
问题 $.when returns a Deferred object for all the multiple ajax calls queried simultaneously. If everything succeeds .done() executes and if any one of the url fails .fail() executes. How to handle partial success states? (i.e) if 5 urls are passed to $.when , if 3 succeeds we need to handle success state and it 2 fails we need to handle failure state. $.when($.getJSON(headerUrl), $.getJSON(tasksUrl), $.getJSON(testingTrackerUrl), $.getJSON(highlightsUrl))) .then(function(headerData, tasksData

AngularJS : chaining http promises $q in a service

谁都会走 提交于 2019-12-10 03:21:01
问题 i have problems when it comes to $http promises in angularjs. i am doing this in my service: (the getSomething function should chain two promises) the second function uses a external callback function! app.service('blubb', function($http, $q) { var self = this; this.getSomething = function(uri, data) { return self.getData(uri).then(function(data2) { return self.compactData(uri, data2); }); }; this.getData = function(uri) { var deferred = $q.defer(); $http.get(uri).success(function(data) {

Making a python program wait until Twisted deferred returns a value

跟風遠走 提交于 2019-12-10 03:14:58
问题 I have a program that fetches info from other pages and parses them using BeautifulSoup and Twisted's getPage. Later on in the program I print info that the deferred process creates. Currently my program tries to print it before the differed returns the info. How can I make it wait? def twisAmaz(contents): #This parses the page (amazon api xml file) stonesoup = BeautifulStoneSoup(contents) if stonesoup.find("mediumimage") == None: imageurl.append("/images/notfound.png") else: imageurl.append

not asynchronous function executed as jQuery Deferred

孤街醉人 提交于 2019-12-09 14:55:11
问题 Lets say I want to process some tasks in the synchronous manner, so I have this function: function executePromiseQueueSync(queue){ var seed = $.Deferred(), finalPromise; finalPromise = _.reduce(queue, function(memo, promise){ return memo.then(function(){ return promise.funct.apply(null, promise.argmnt); }); }, seed.promise()); seed.resolve(); return finalPromise; } Now I can use it to process some files: _.each(fileList, function(element, index, list){ _.each(element, function(el, idx, lst){

twisted deferred/callbacks and asynchronous execution

强颜欢笑 提交于 2019-12-09 13:05:49
问题 I'm trying to figure out how can i make my code more asynchronous using twisted. A function returns a deferred object then i add a list of callbacks the first callback will be called after the deferred function provides some result through deferred_obj.callback then, in the chain of callbacks, the first callback will do something with the data and call the second callback and etc. however chained callbacks will not be considered asynchronous because they're chained and the event loop will

Is it true that deferral should be added for any async operation?

廉价感情. 提交于 2019-12-08 18:43:32
问题 According to Likness (p. 164, "Building Windows 8 Apps with C# and XAML"), "When performing asynchronous tasks, you must ask for a deferral." So if I'm not taking him out of context, this code: private async Task<System.Collections.Generic.KeyValuePair<string, string>> SelectAContactForASlot() { KeyValuePair<string, string> kvp; var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker(); contactPicker.CommitButtonText = "Select"; var contact = await contactPicker

jQuery.Deferred().then, how to resolve with multiple parameters

 ̄綄美尐妖づ 提交于 2019-12-08 15:17:12
问题 So my API expects that when a particular deferred is resolved it gets 2 params. fn().done(function(arg1, arg2) { console.log(arg1, arg2); }).fail(function(err) { console.error(err); }); Now relating to the fn function above, it needs to first wait for some other deferred to return before resolve. function other() { // stubbed out to always resolve return $.Deferred().resolve().promise(); } function fn() { return other().then(function() { return [1, 2]; }); } But this is not working, because