Skip to content

Commit d08015a

Browse files
committed
Note what defer.resolve and defer.reject do. Closes jquerygh-693
1 parent 9e8fcac commit d08015a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

page/code-organization/deferreds/examples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $.cachedGetScript = function( url, callback ) {
3939
};
4040
```
4141

42-
One promise is cached per URL. If there is no promise for the given URL yet, then a deferred is created and the request is issued. If it already exists, however, the callback is attached to the existing deferred. The big advantage of this solution is that it will handle both complete and inbound requests transparently. Another advantage is that a deferred-based cache will deal with failure gracefully. The promise will end up rejected which can be tested for by providing an error callback:
42+
One promise is cached per URL. If there is no promise for the given URL yet, then a deferred is created and the request is issued. When the request is complete, the deferred is resolved (with `defer.resolve`); if an error occurs, the deferred is rejected (with `defer.reject`). If the promise already exists, the callback is attached to the existing deferred; otherwise, the promise is first created and then the callback is attached. The big advantage of this solution is that it will handle both complete and inbound requests transparently. Another advantage is that a deferred-based cache will deal with failure gracefully. The promise will end up rejected which can be tested for by providing an error callback:
4343

4444
```
4545
$.cachedGetScript( url ).then( successCallback, errorCallback );

0 commit comments

Comments
 (0)