-
Notifications
You must be signed in to change notification settings - Fork 263
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
Document jQuery.ready as Promise-consumable #530
Conversation
</argument> | ||
</signature> | ||
<longdesc> | ||
<p>The <code>$.ready.promise()</code> method provides a Promise interface to the document ready event. See also <code><a href="/ready/">ready()</a></code>, which makes use of this.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the standards sense, it doesn't provide a Promise interface but instead a thenable one. This has been one of the reasons we've been hesitant to document this. The other is that we may try to make jQuery.Deferred optional in a future version, so it's almost as if we're documenting and deprecating this at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand it isn't a standards Promise (the definition of that seems still in flux, too), I just tried to match our terminology from elsewhere. What should this be called?
deferred.promise
: "type=Promise", "Return a Deferred's Promise object.", "The Promise exposes only the Deferred methods needed to attach additional handlers or determine the state"- Types: "Promise Object", "a subset of the methods of the Deferred object"
promise
: "a Promise object to observe when all [actions] have finished"
The |
The |
Also: * Categorise jQuery.holdReady in events/document-loading, to match ready() and jQuery.ready.promise(). * Categorise jQuery.holdReady in properties/global-jquery-object-properties, to match jQuery.fx.off() and jQuery.ready.promise(). Fixes #205
Agreed, |
I actually think it might be as easy as |
@Krinkle I don't think we want to document the |
$.when(
$.ajax( templateURL ),
$.ajax( dataURL ),
$.ready
).then( function( template, data ) {
$( "#target" ).html( applyTemplate( template[ 0 ], data[ 0 ] ) );
} ); This is how you decouple initialization code while enabling preemptive asynchronous operations and keeping everything readable. Having a |
Yes, the ready promise is nice to use. Two issues with it:
Edit by @gnarf - made into checkboxes |
Okay,
|
|
Is this PR still relevant? It's more than a year old. |
@timmywil Could you please check this? Thanks (old PR). |
Oh, sorry. It depends on the resolution of the ticket @gnarf linked. I guess it's been longer than I thought, but we finally have a PR for it. I'm on the fence about whether it's worth the bytes. If we merge the PR, |
Thenable?
|
It looks like we will be getting rid of |
Shouldn't that pull request be merged? https://jquery.com/upgrade-guide/3.0/ says that "Feature: jQuery.ready promise is formally supported" but I don't see it on https://api.jquery.com |
The PR needs updating first. |
jquery/jquery#1778 has been fixed so this PR should no longer be blocked. |
@Krinkle With jQuery 3.0 we're exposing Would you like to update this PR to reflect those changes? It would be great to get that done! |
Also:
jQuery.holdReady
in events/document-loading,to match
ready()
andjQuery.ready.promise()
.jQuery.holdReady
in properties/global-jquery-object-properties,to match
jQuery.fx.off()
andjQuery.ready.promise()
.Fixes #205