deferred

worklight 5.0.6 JsonRestStore, use of Promises

旧时模样 提交于 2019-12-12 02:54:43
问题 This was originally a question about the Worklight documentation, it transpires that my real question is about JQuery's Deferred/Promise API and the promise.then() function. Context: The documentation for the 5.0.6 JsonRestStore API gives examples of using the new Promise capability offering two possible formulations. someFunction.then( successCallback, errorCallback, optionalProgressCallback); And someFunction().then(successCallback).fail(errorCallback) These two approaches seem, as comments

Chaining promise and defered with a for loop in angular application

假装没事ソ 提交于 2019-12-11 23:23:05
问题 I try to use promise and defered in an angular application. I use two functions $scope.checkQuestions() and $scope.saveExerciseApi() but the problem is that the second one is launched before the first has finished wich is not what I had expected. The first one call promises to update each questions (with a REST service) and then update $scope.formQuestion[] array which is used in a form on the page. $scope.Questions and $scope.Exercises are already promise object to update and create entities

Wait for the end of TWO asynchrounous functions before firing a third (jQuery Deferred ?)

喜欢而已 提交于 2019-12-11 20:49:48
问题 I'm trying to understand jQuery's Deferred , but inspite of samples, I can't achieve what I want to do. So, I'd like to call 2 functions asynchrounously, and, when BOTH are ended, call another one. Here's my code function1(); function2(); function3(); function1() and function2() make an ajax call to my ASP.NET application, and they perfectly work. They must be ended before function3() starts. I'm reading and reading again the documentation but function3() doens't wait for the end of the two

What comes first .always() or .then() callbacks in jQuery? [duplicate]

爱⌒轻易说出口 提交于 2019-12-11 13:36:09
问题 This question already has answers here : jQuery: What is the difference between deferred.always() and deferred.then()? (4 answers) Closed 4 years ago . If you have a function which has both .then and .always callbacks, which one will get executed first? 回答1: Taken from the deferred.resolve() documentation: When the Deferred is resolved, any doneCallbacks added by deferred.then() or deferred.done() are called. Callbacks are executed in the order they were added. Example below: var $logger = $(

When should I use Q.defer and when just Promise.resolve/reject?

扶醉桌前 提交于 2019-12-11 10:05:26
问题 I'm using nodejs and was wondering when should I use Q defer, and when just use Promise.resolve/reject? I saw a lot of examples of both kinds, for example: // with Q defer fucntion oneWay(myVal) { var deffered = Q.defer(); if (myVal < 0) { deffered.reject(new Error('nope')); } else { deffered.resolve('yay'); } return deffered.promise; } // native Promise fucntion orAnother(myVal) { if (myVal < 0) { return Promise.reject(new Error('nope')); } else { return Promise.resolve('yay'); } } What's

Dojo using deferred functions to get data in ajax callback function

流过昼夜 提交于 2019-12-11 09:48:40
问题 I have a function with a return however in the function there is an async request which holds the value that is suppose to be returned by the function. I understand with the nature of async request the function will complete and not return a value while waiting on the async function to complete. I attempted to use dojo deferred functions to have my function PostInformation() to return a value within the ajax request callback. I am having some issues and i am not sure where my issue is. Under

YDN-DB with multiple deferred

隐身守侯 提交于 2019-12-11 07:43:42
问题 Im trying to use multiple deferred with jquery $.when but so far no luck, this is my code: var req = $.when(db.count('items'),db.values('items'),db.get('config', 1)); req.done(function(count,r,config) { var currency = config.currency; if(count > 0){ var n = r.length; for (var i = 0; i < n; i++) { var id = r[i].id; var itemId = r[i].itemId; console.log('ID: '+id+' itemID: '+itemId+' Currency: '+currency); } } }); My sample isn't working so hope you guys can help me, I searched everywhere for a

Deferred that extends Promise

谁说胖子不能爱 提交于 2019-12-11 05:54:41
问题 How to implement a Deferred promise that extends Promise? It's important to extend Promise for type-safe usage where a typical Promise is expected. Following implementation export class Deferred<T> extends Promise<T> { public _resolveSelf; public _rejectSelf; constructor() { super( (resolve, reject) => { this._resolveSelf = resolve this._rejectSelf = reject } ) } public resolve(val:T) { this._resolveSelf(val) } public reject(reason:any) { this._rejectSelf(reason) } } throws TypeError: _this

Deferred Shadow Mapping GLSL

北城以北 提交于 2019-12-11 03:04:03
问题 Im currently implementing a deferred rendering pipeline and im stuck with shadow mapping. Ive already implemented it succesfully into a forward pipeline. The Steps i do are: Get Position in Light View Convert to light view clip space Get shadow tex coords with * 0.5 + 0.5; check depth Edit: Updated code with new result image: float checkShadow(vec3 position) { // get position in light view mat4 invView = inverse(cameraView); vec4 pEyeDir = sunBias * sunProjection * sunView * invView * vec4

Working with Ajax Promises / Deferred

我怕爱的太早我们不能终老 提交于 2019-12-10 23:59:14
问题 I am trying to get an Ajax promise using the code below. Because my function makes another ajax call before initiating the actual one , for getting the authKey , The promise (that should have been returned) from the actual call is null, & I cannot use .then() on it because I think I am not getting anything in return from it. I am not sure why. What am I doing wrong here? Is there any other way to go about this. I call getAjaxPromise() like mentioned below but get null in return: