Skip to content

Deferred example suggestion #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jinz2014 opened this issue Dec 29, 2015 · 1 comment
Closed

Deferred example suggestion #693

jinz2014 opened this issue Dec 29, 2015 · 1 comment

Comments

@jinz2014
Copy link

Hi Reviewer,

For the following code at the link http://learn.jquery.com/code-organization/deferreds/examples/,
it is not very clear how defer.resolve and defer.reject work in the function passed to the $.Deferred() method.

Thank you for reading the issue.

var cachedScriptPromises = {};

$.cachedGetScript = function( url, callback ) {
    if ( !cachedScriptPromises[ url ] ) {
        cachedScriptPromises[ url ] = $.Deferred(function( defer ) {
            $.getScript( url ).then( defer.resolve, defer.reject );
        }).promise();
    }
    return cachedScriptPromises[ url ].done( callback );
};
@jinz2014
Copy link
Author

I forgot my suggestion.

Thank you for your email.

From: Karl Swedberg [mailto:notifications@github.com]
Sent: Sunday, March 13, 2016 5:39 PM
To: jquery/learn.jquery.com
Cc: JIN, ZHEMING
Subject: Re: [learn.jquery.com] Deferred example suggestion (#693)

Closed #693#693 via d08015ahttps://github.com/jquery/learn.jquery.com/commit/d08015a310858e480c746c7e145303be1aba500e.


Reply to this email directly or view it on GitHubhttps://github.com//issues/693#event-588019391.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant