Document jQuery.ready as Promise-consumable#530
Document jQuery.ready as Promise-consumable#530Krinkle wants to merge 1 commit intojquery:masterfrom Krinkle:issue/205
Conversation
entries/jQuery.ready.promise.xml
Outdated
There was a problem hiding this comment.
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.
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.holdReadyin events/document-loading,to match
ready()andjQuery.ready.promise().jQuery.holdReadyin properties/global-jquery-object-properties,to match
jQuery.fx.off()andjQuery.ready.promise().Fixes #205