Skip to content

Instantly share code, notes, and snippets.

@timmywil
Created October 27, 2011 14:11
Show Gist options
  • Save timmywil/1319648 to your computer and use it in GitHub Desktop.
Save timmywil/1319648 to your computer and use it in GitHub Desktop.
Modules with deferred dependencies
// This could be compatible with jQuery's Deferred implementation,
// futures.js (slightly different syntax) or any one of a number
// of other implementations
define(['lib/Deferred'], function( Deferred ){
var defer = new Deferred();
require(['lib/templates/?index.html','lib/data/?stats'],
function( template, data ){
defer.resolve({ template: template, data:data });
}
);
return defer.promise();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment