Permalink
Browse files

Fix example to show how to preserve Deferred

The initial Deferred object returned from $.wait will get lost if chained onto a call to .done(), .then(), etc, since those will return a Promise object.
  • Loading branch information...
1 parent 097a03d commit 961cb60ed1887db731cc0dee360e1df8cdb2b41d @MoonScript committed Mar 6, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 README.md
View
@@ -14,7 +14,9 @@ $.wait(500).then(function(){
This is similar to [_.delay](http://underscorejs.org/#delay), except that you can cancel the *done* callbacks by calling `.reject()` on the returned Deferred object:
```JavaScript
-var deferred = $.wait(5000).done(function(){
+var deferred = $.wait(5000);
+
+deferred.done(function(){
console.log('This won\'t run if the deferred object is rejected within 5 seconds.');
});

0 comments on commit 961cb60

Please sign in to comment.