Category Archives: Async

Consistency Problems With APIs In JavaScript Promise Libraries

Promises are a powerful way to handle asynchronous code in JavaScript. They give us a lot of opportunity to clean up code, and to write code that can register work to be done when the promise is resolved, whether or … Continue reading 

Also posted in Javascript, JQuery, NodeJS, Promises, Qjs, RSVPjs, User Experience, WinJS | 10 Comments

Jasmine.Async: Making Asynchronous Testing With Jasmine Suck Less

I love Jasmine. It’s a great BDD-style testing framework for browser based JavaScript, and my preferred tool for doing that kind of work. But the asynchronous testing story in Jasmine is painful at best. Jasmine’s Async Is Painful Here’s a short example of … Continue reading 

Also posted in Jasmine, jasmine-async, Javascript, Unit Testing | 26 Comments

Asynchronous Unit Tests With Mocha, Promises, And WinJS

Before I get in to the guts of this post, you need to read Christopher Bennage’s post on how we have our Mocha test suite set up for our Win8 / WinJS project. It’s not the best setup, but it … Continue reading 

Also posted in ChaiJS, CommonJS, Javascript, MochaJS, Testing, WinJS | 11 Comments

Partially Applied Functions In JavaScript

I’m finding myself doing more and more functional programming with JavaScript lately – especially in recent days with this WinJS project I’m working on, and the heavy use of promises that it encourages. This feels a little odd to me, … Continue reading 

Also posted in ECMAScript, Functional, Javascript, Underscore, WinJS | 8 Comments

Want To Build Win8/WinJS Apps? You Need To Understand Promises.

If you’re not following me on Twitter, you may not know about my current project work. I’m working with Christopher Bennage and the Microsoft Patterns & Practices group to build a Windows 8, WinJS, Metro-style app with HTML, CSS and … Continue reading 

Also posted in CommonJS, Javascript, WinJS | 4 Comments

Providing Synchronous / Asynchronous Flexibility With jQuery.when

I’ve quickly become a fan of jQuery’s Deferred / Promise features. They’ve been around for a little bit now, but I only recent started using them and they’ve helped me solve a number of problems with my asynchronous JavaScript code. … Continue reading 

Also posted in Backbone, Javascript, JQuery, Marionette | 8 Comments

TrafficCop: A jQuery Plugin To Limit AJAX Requests For A Resource

A while back, I wrote about asynchronous template loading for Backbone applications. At the bottom of that post, I showed some code that I wrote which would limit the number of AJAX calls that are made to the server, to … Continue reading 

Also posted in Javascript, JQuery | 4 Comments

Asynchronously Load HTML Templates For Backbone Views

UPDATE: It turns out this is a really bad idea. Don’t async fetch individual templates. In the end, having done asynchronous fetching of individual templates on a few productions apps, it’s a really bad idea. The network latency and multiple … Continue reading 

Also posted in Backbone, Javascript, JQuery, Marionette, Principles and Patterns, User Experience | 29 Comments

Rewriting My ‘Guaranteed Callbacks’ Code With jQuery Deferred

In a previous post, I showed some code that I wrote to guarantee the execution of a callback method after a Backbone collection was loaded. Even if you added the callback after the collection had been loaded, it would run. Shortly … Continue reading 

Also posted in Backbone, Javascript, JQuery, Marionette | 5 Comments

Get A Model From A Backbone Collection Without Knowing If The Collection Is Loaded

In working with a client recently, we ran in to a rather sticky situation. We were setting up a route to “persons/:id”, and as you would expect, we wanted to load the person in question and display the details of … Continue reading 

Also posted in Backbone, Javascript, Marionette | 1 Comment