deferred

Conditionals on a chained deferred in jquery

蓝咒 提交于 2019-12-05 22:29:25
Let say I chained the $.Deferred like this. $.each(data, function(k, v) { promise.then(function() { return $.post(...); }).then(function(data) { if(data)... // here is the conditions return $.post(...); }).then(function(data) { if(data)... // here is another condition return $.post(...); }) }); promise.done(function() { console.log("All Done!"); }); Am I doing it right? how do I prevent the next chain to execute if the condition return false, and where do I do this: if(data){ console.log('Success'); } Can that code be in between those .then s? Joey, whether or not you are doing it right

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

瘦欲@ 提交于 2019-12-05 21:26:25
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. From about 2 meters away in our game's units (64 units/meter): A few centimeters away . Note that the

equivalent of $q.when in angular 2

可紊 提交于 2019-12-05 20:34:16
I am used to using $q with angular 1. I am migrating to angular 2. Is there an equivalent that provide a .when() method ? for example I need to migrate this: .service('updateProDB', [ '$rootScope', 'connectionStatus', '$q', 'storageService', 'sendToServer', '$ionicPopup', function ($rootScope, connectionStatus, $q, storageService, sendToServer, $ionicPopup) { 'use strict'; var dbReadyDeferred = $q.defer(), prodata = [], prodataFieldNames = []; this.get = function () { var debugOptionUseLocalDB = 0, prodata = [], serverAttempts = 0; if (debugOptionUseLocalDB) { return

Angular/Jasmine testing with deffered promises

和自甴很熟 提交于 2019-12-05 13:22:27
I am testing a controller using a combination of angular and jasmine, and am not completely sure about using deffered promises. This is my spec code. describe('Controller Tests', function(){ var scope, searchAPI; beforeEach(function(){ var mockSearchAPI = {}; module('myApp', function($provide){ $provide.value('searchAPI', mockSearchAPI); }); }); inject(function($q){ var testData = {"message":"hi"}; mockSearchAPI.executeSearch = function(){ var defer = $q.defer(); defer.resolve(testData); return defer.promise; }; }); beforeEach('Main Search Controller Tests', function(){ function($controller,

First attempt at lazy loading (deferring the load of embedded YouTube videos) - how can I do this more gracefully?

寵の児 提交于 2019-12-05 11:39:51
Yesterday I decided to improve the way my website loads YouTube videos by only embedding them when a user requests them. Sometimes a page could have as many as 30 videos on, and this would take a long time to load. This is the first time I've attempted a "lazy loading" method of anything, and I figured it would be well worth asking: What can I do to improve on this? How can I make it a bit more graceful? Does this completely miss the point of deferred loading? JSFiddle . Ignore the styling as that's irrelevant here. The way this works is by first placing an anchor on the page containing the

Reuse jQuery.post() / jQuery.Deferred() object

你。 提交于 2019-12-05 05:27:26
the simplest example of what I'm looking for is this: var messageLoader = $.post("api/user/messages", {api:data}) messageLoader.done(function(data){ //do something }); This works brilliantly, but only once. If I want to update the data, I have to redefine everything. I can't seem to find any call for the Deferred Object that let's me restart it. i.e. messageLoader.redo() , which ideally would re-do the POST request, and subsequently call the same "done" handler without me having to re-define it. I could put it all in a function and simply call that function again, but that's not what I'm

jQuery deferred behaviour in for loop

瘦欲@ 提交于 2019-12-05 02:47:16
问题 I recently asked a question about the behaviour of jquery deferred in a for loop. Link here I received a working answer but I don't understand why it works. If I have the following code: function update(callbacks) { return $.Deferred(function(dfr) { setTimeout(function() { callbacks.success() }, 1000); dfr.resolve(); }).promise(); } function updateElements(deferreds) { for (var i = 0; i < 5; i++) { (function() { var index = i; deferreds.push(update({ success: function() { alert(index); } }));

Making a python program wait until Twisted deferred returns a value

限于喜欢 提交于 2019-12-05 02:11:15
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(stonesoup.find("mediumimage").url.contents[0]) usedPdata = stonesoup.find("lowestusedprice") newPdata =

Failed to resolve class via deferred binding

杀马特。学长 韩版系。学妹 提交于 2019-12-05 00:08:31
// ...some imports public class Menu { final MenuMaker myClass = GWT.create(MenuMaker.class); // ERROR My ...gwt.xml: ... <generate-with class="com.gwt.rebind.MenuGenerator"> <when-type-assignable class="com.gwt.client.MenuMaker" /> </generate-with> ... All work perfectly when I run compile in DevMode but when I "Build the project with the GWT compiler" I get this error: [ERROR] Line 15: Failed to resolve 'com.gwt.client.MenuMaker' via deferred binding Scanning for additional dependencies: jar:file:/C:/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201208080121-rel-r42/gwt-2.4.0/gwt

Defer block is not executed

…衆ロ難τιáo~ 提交于 2019-12-04 04:00:49
问题 I have the following swift code executing in playground: func A() { print ("Hello") guard 1 == 2 else { return } defer { print ("World") } } A() I expected to see Hello World Instead only the Hello is printed. Why is this? What am I missing? Here is a better example: enum MyError: ErrorType { case TriggerDefer } func throwsMyError() throws { let myzero = Int(arc4random_uniform(1)) guard myzero > 1 else { throw MyError.TriggerDefer } } func A() throws { try throwsMyError() defer { print (