<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Providing Synchronous / Asynchronous Flexibility With jQuery.when</title>
	<atom:link href="http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/</link>
	<description>Better Than Yesterday</description>
	<lastBuildDate>Fri, 24 May 2013 06:39:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Paul Barton</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2327</link>
		<dc:creator>Paul Barton</dc:creator>
		<pubDate>Fri, 30 Mar 2012 20:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2327</guid>
		<description>Good example of this usage is caching Ajax calls :

(function($, exports) {
    exports.cache = {};
    exports.getAjaxData = function(url) {
        return cache[url] &#124;&#124; $.get(url);
    };
})(jQuery, window);

$when(getAjaxData(&#039;foo.html&#039;)).then(function(response) {
    //do something with data
    cache[&#039;foo.html&#039;] = response;
});</description>
		<content:encoded><![CDATA[<p>Good example of this usage is caching Ajax calls :</p>
<p>(function($, exports) {<br />
    exports.cache = {};<br />
    exports.getAjaxData = function(url) {<br />
        return cache[url] || $.get(url);<br />
    };<br />
})(jQuery, window);</p>
<p>$when(getAjaxData(&#8216;foo.html&#8217;)).then(function(response) {<br />
    //do something with data<br />
    cache['foo.html'] = response;<br />
});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derick Bailey</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2324</link>
		<dc:creator>Derick Bailey</dc:creator>
		<pubDate>Fri, 30 Mar 2012 00:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2324</guid>
		<description>the real value of using $.when is not caring if it&#039;s a sync or async call, as i tried to show in this post. 

if your function returns a promise, you can do this:

var foo = doSomething();
foo.done(function(){
  // it&#039;s done
});

but if, for some reason, the doSomething function changes so that it no longer returns a promise, but now returns a plain javascript object or a string or something, this code will break because there won&#039;t be a &quot;done&quot; method on the returned object.

by using $.when(foo).then(function(){...}) instead, we don&#039;t care what the return type is. it can be a promise, in which case the callback will fire when the promise resolves. or, it can be a plain old object or a string or anything else, in which case the callback will fire immediately.</description>
		<content:encoded><![CDATA[<p>the real value of using $.when is not caring if it&#8217;s a sync or async call, as i tried to show in this post. </p>
<p>if your function returns a promise, you can do this:</p>
<p>var foo = doSomething();<br />
foo.done(function(){<br />
  // it&#8217;s done<br />
});</p>
<p>but if, for some reason, the doSomething function changes so that it no longer returns a promise, but now returns a plain javascript object or a string or something, this code will break because there won&#8217;t be a &#8220;done&#8221; method on the returned object.</p>
<p>by using $.when(foo).then(function(){&#8230;}) instead, we don&#8217;t care what the return type is. it can be a promise, in which case the callback will fire when the promise resolves. or, it can be a plain old object or a string or anything else, in which case the callback will fire immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: João Mamede</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2323</link>
		<dc:creator>João Mamede</dc:creator>
		<pubDate>Thu, 29 Mar 2012 20:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2323</guid>
		<description>Derick, I can see the value and I&#039;ve used this approach for async calls but for sync ones not sure if it really helps me rather than allowing the execution of multiple (chained or not) callbacks (e.g. with the done() method).

Am I right? Thanks for another great post! </description>
		<content:encoded><![CDATA[<p>Derick, I can see the value and I&#8217;ve used this approach for async calls but for sync ones not sure if it really helps me rather than allowing the execution of multiple (chained or not) callbacks (e.g. with the done() method).</p>
<p>Am I right? Thanks for another great post! </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle_Murphy</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2321</link>
		<dc:creator>Kyle_Murphy</dc:creator>
		<pubDate>Wed, 28 Mar 2012 04:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2321</guid>
		<description>Holy crap, thanks so much.  Am now using it for synchronizing multiple ajax calls.</description>
		<content:encoded><![CDATA[<p>Holy crap, thanks so much.  Am now using it for synchronizing multiple ajax calls.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Elms</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2320</link>
		<dc:creator>Gareth Elms</dc:creator>
		<pubDate>Tue, 27 Mar 2012 20:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2320</guid>
		<description>Thanks for bringing this under my radar I read all your posts here.

I had to write something fairly similar and for what it&#039;s worth here it is 
http://jsfiddle.net/bqC6U/3/My single page app makes an ajax call immediately after a page refresh to load the data. I have routed js modules that are dependent on this data waiting to render the backbone views. I didn&#039;t want to trigger an event like &quot;dataLoaded&quot; in case the event was subscribed to after it had already fired. Any feedback (negative I assume) on my jsfiddle would be appreciated. I expect this problem has been solved before much more elegantly many years ago but my code is at least robust. Or is it?</description>
		<content:encoded><![CDATA[<p>Thanks for bringing this under my radar I read all your posts here.</p>
<p>I had to write something fairly similar and for what it&#8217;s worth here it is <br />
<a href="http://jsfiddle.net/bqC6U/3/My" rel="nofollow">http://jsfiddle.net/bqC6U/3/My</a> single page app makes an ajax call immediately after a page refresh to load the data. I have routed js modules that are dependent on this data waiting to render the backbone views. I didn&#8217;t want to trigger an event like &#8220;dataLoaded&#8221; in case the event was subscribed to after it had already fired. Any feedback (negative I assume) on my jsfiddle would be appreciated. I expect this problem has been solved before much more elegantly many years ago but my code is at least robust. Or is it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derick Bailey</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2319</link>
		<dc:creator>Derick Bailey</dc:creator>
		<pubDate>Tue, 27 Mar 2012 14:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2319</guid>
		<description>Oh nice. I didn&#039;t know jQuery had a proxy method for that. Most of the time, I have Underscore.js in my apps, so I tend to use _.bind and _.bindAll. Looks like they do the same thing, though. Good to know.</description>
		<content:encoded><![CDATA[<p>Oh nice. I didn&#8217;t know jQuery had a proxy method for that. Most of the time, I have Underscore.js in my apps, so I tend to use _.bind and _.bindAll. Looks like they do the same thing, though. Good to know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Brewer</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2318</link>
		<dc:creator>Tom Brewer</dc:creator>
		<pubDate>Tue, 27 Mar 2012 14:28:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2318</guid>
		<description>Another jQuery gem that is often overlooked is the jQuery.proxy method: https://gist.github.com/2216288 Great article by the way. I was not aware of jQuery.when.</description>
		<content:encoded><![CDATA[<p>Another jQuery gem that is often overlooked is the jQuery.proxy method: <a href="https://gist.github.com/2216288" rel="nofollow">https://gist.github.com/2216288</a> Great article by the way. I was not aware of jQuery.when.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Cadwallader</title>
		<link>http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/#comment-2317</link>
		<dc:creator>Dave Cadwallader</dc:creator>
		<pubDate>Tue, 27 Mar 2012 14:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=857#comment-2317</guid>
		<description>Gotta love patterns that let you work smarter, not harder.  Thanks for the great write-up!</description>
		<content:encoded><![CDATA[<p>Gotta love patterns that let you work smarter, not harder.  Thanks for the great write-up!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
