deferred

ios deferred location updates fail to defer

夙愿已清 提交于 2019-11-30 14:43:40
I am looking into using deferred location updates for an iOS activity tracker, which allows location services in background. I've implemented the suggested code snippets (see below). In Xcode debugging, deferred locations attempt to start a few times until location data comes in at about 1 per second. After that, it claims to succeed in starting deferrals, and the callback for the finish trigger also succeeds after the specified time period expires. However during the time, the location handler still runs once per second. I've read that this is because the phone hasn't deemed itself ready to

jquery when/then (also when/done) not waiting

旧巷老猫 提交于 2019-11-30 06:58:00
I've looked at many samples that use this syntax, but I can't see what I"m doing wrong. The "then" function is running before the ajax call returns. I've tried also using $.deferred and a few other patterns to no avail. Can someone see what I'm missing? I have debugged and can see the calls being made from inside the done/then before the ajax call returns it's success (or error) data. Thanks for any help. Main call: this.addFirstTask = function(task) { var totalHours = GetHours(); $.when(totalHours).done(function (data) { task.TaskHours(data); self.add(task); }); }; It is calling the following

How do I debug my asynchronous, promise based code if the library is swallowing all the exceptions?

懵懂的女人 提交于 2019-11-30 06:44:36
The Problem JSFiddle : http://jsfiddle.net/missingno/Gz8Pe/2/ I have some code that looks like this: var d = new Deferred(); d.resolve(17); return d.then(function(){ //do some stuff... }) .then(function(){ var obj = a_funtion_that_returns_null_on_IE(); var x = obj.some_property; //BOOM! }); The problem is that when I am on IE all I can see are 'obj' is null or not an object errors, without any reference to the corresponding line number and without the debugger halting at the offending line (like I wish it would). This kind of issue is making the code a pain to debug and the only solutions I

jquery deferred in .each loop

情到浓时终转凉″ 提交于 2019-11-30 06:31:33
问题 This should be a simple one. I have a function that is called and I need to wait for all the async operations to complete. what I want is something like this... self.processSchema(data).done(function(results){ //do stuff}); The processSchema function loops using $.each and calls an async method. var processSchema = function(data) { var def = new $.Deferred(); $.each(table, function() { //calls an async SQLitePlugin method db.executeSql(sql, data, function(tx, results){ def.resolve(results); }

[翻译]在jQuery 1.5中使用deferred对象

十年热恋 提交于 2019-11-30 05:34:15
原文: http://www.erichynds.com/jquery/using-deferreds-in-jquery/ 翻译:三生石上( http://cnblogs.com/sanshi/ ) 译者注: 1. Deferred 是jQuery1.5新增的一个特性,很多人把它翻译成 “异步队列”,我觉得比较靠谱,毕竟和“延迟”没啥关系,不过这篇文章中我还采用deferred这个单词。 2. 这篇文章在jQuery1.5发布博客中提到,也是目前介绍deferred比较经典和深入的文章。鉴于目前中文资料比较少,特别翻译出来供大家学习参考。 3. 通篇采用意译的方式,如有不当还请大家提出。 jQuery1.5 中新增的Deferreds对象,可以将任务完成的处理方式与任务本身解耦合。这在JavaScript社区没什么新意,因为Mochikit和Dojo两个JS框架已经实现了这个特性很长一段时间了。但是随着 Julian Aubourg 对jQuery1.5中AJAX模块的重写,deferreds理所当然成为了内部的实现逻辑。使用deferreds对象,多个回调函数可以被绑定在任务完成时执行,甚至可以在任务完成后绑定这些回调函数。这些任务可以是异步的,也可以是同步的。 更重要的是,deferreds已经作为$.ajax()的内部实现

CollectionView.DeferRefresh() throws exception

做~自己de王妃 提交于 2019-11-30 04:23:34
问题 There are cases when you have many UI updates due a massive amount of INotifyChangedProperties events. In that case you might want to signal the changes to UI only once when all the properties are set like in a batch. I found this great article that explains how to defer the refresh of the ViewCollection: http://marlongrech.wordpress.com/2008/11/22/icollectionview-explained/ However I get an exception when the View is deferred and I try to add something to the collection. I don't understand

JQuery - $.when syntax for array of Deferred objects [duplicate]

瘦欲@ 提交于 2019-11-29 23:41:34
问题 This question already has answers here : Pass in an array of Deferreds to $.when() (9 answers) Closed 5 years ago . It is the first time I am using $.when and I am having difficulty with the syntax. I have code similar to simplified example below. It works (if I haven't caused an error when I simplified it). My problem is that I don't know home many elements the customerIds array would contain. var customerIds = new [1, 2, 3]; $.when( getCustomerData(customerIds[0]), getCustomerData

AngularJS - why promises ($q) with $http?

我与影子孤独终老i 提交于 2019-11-29 23:19:22
I am learning AngularJS after converting from jQuery for a few years. And some bits are much more intuitive. Some not so much :). I am trying to get my head around the use of promises, particularly $q in use with $http and there does not seem to be too much information around these two combined that I can find. Why would I use promises in place of the success/error callback? They both make uses of callbacks in reality, so why is a promise considered better? E.g. I could set up a get(...) function like follows: function get(url, success, error) { success = success || function () {}; error =

Twisted: Waiting for subtasks to finish

删除回忆录丶 提交于 2019-11-29 21:48:39
问题 In my code, I have two hypothetical tasks: one gets urls from a generator and batch downloads them using Twisted's Cooperator, and the other takes a downloaded source and asynchronously parses it. I'm trying to encapsulate all of the fetch and parse tasks into a single Deferred object that calls back when all pages are downloaded and all sources are parsed. I've come up with the following solution: from twisted.internet import defer, task, reactor, threads from twisted.web.client import

ios deferred location updates fail to defer

放肆的年华 提交于 2019-11-29 21:11:34
问题 I am looking into using deferred location updates for an iOS activity tracker, which allows location services in background. I've implemented the suggested code snippets (see below). In Xcode debugging, deferred locations attempt to start a few times until location data comes in at about 1 per second. After that, it claims to succeed in starting deferrals, and the callback for the finish trigger also succeeds after the specified time period expires. However during the time, the location