Skip to content

Conversation

@Krinkle
Copy link
Member

@Krinkle Krinkle commented Mar 16, 2017

Technically replacing Deferred with Thenable would work, but mentioning Deferred and Promise directly should make this easier to understand for new and existing users.

Fixes #906.

@Krinkle
Copy link
Member Author

Krinkle commented Mar 16, 2017

This is a minimal change to unblock #983. A few other changes to consider separately:

  • Add an optional second parameter that is the same, to indicate that it takes variadic arguments, similar to append().
  • Add a secondary signature with Anything and improve documentation on the behaviour of wrapping non-thenable values.

pages/Types.html Outdated
<p>As of jQuery 1.5, the <a href="/jQuery.ajax/">$.ajax()</a> method returns the jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the <a href="/jQuery.ajax/#jqXHR">jqXHR section of the $.ajax entry</a>
</p>
<h2 id="Thenable">Thenable</h2>
<p>Any object with a <code>then</code> method that returns a <a href="#Promise">Promise</a>-compatible object.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should stick to the definition at https://promisesaplus.com/#point-7 i.e. the only assumption about then is that it's a function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mentioning how it relates to promises somehow would clarify things but it should be obvious this is only an advisory remark and not part of the definition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've simplified the phrasing, leaving out the Promise mention for now.

Technically replacing Deferred with Thenable would work, but
mentioning Deferred and Promise directly should make this
easier to understand for new and existing users.

Fixes #906.
<p>As of jQuery 1.5, the <a href="/jQuery.ajax/">$.ajax()</a> method returns the jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the <a href="/jQuery.ajax/#jqXHR">jqXHR section of the $.ajax entry</a>
</p>
<h2 id="Thenable">Thenable</h2>
<p>Any object that has a <code>then</code> method.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the spec at https://promisesaplus.com/#point-7 mentions functions with a then method as acceptable input as well.

That's a little weird one but technically we're still accepting those so maybe we should keep our definition identical to the Promises/A+ one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgol I considered that but found it more confusing than useful. All functions are objects. So this isn't contradictory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, OK. I guess it was mentioned as that's the only object that has a non-"object" typeof.

@mgol mgol merged commit 3ab6720 into jquery:master Mar 20, 2017
@Krinkle Krinkle deleted the thenable branch March 20, 2017 22:37
@Krinkle Krinkle mentioned this pull request Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants