Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#8856 closed enhancement (fixed)

Request: deferred.isUnresolved()

Reported by: giskard22 Owned by: jaubourg
Priority: blocker Milestone: 1.7
Component: deferred Version: 1.5.2
Keywords: 1.7-discuss Cc:
Blocked by: Blocking:

Description (last modified by ajpiano)

Sometimes I want to see if a Deferred is still pending. I have to do:

if (def.isResolved() || def.isRejected()) ...

It would be easier to just check def.isUnresolved().

Change History (20)

comment:1 Changed 10 years ago by timmywil

Component: unfileddeferred
Priority: undecidedlow

comment:2 Changed 10 years ago by john

Let's consider this for 1.7.

comment:3 Changed 10 years ago by timmywil

Milestone: 1.next1.7
Status: newopen

comment:4 Changed 10 years ago by jaubourg

I'd vote for isPending()

comment:5 Changed 10 years ago by john

Milestone: 1.71.next

comment:6 Changed 10 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:7 Changed 10 years ago by Rick Waldron

Description: modified (diff)

+1,

comment:8 Changed 10 years ago by jaubourg

+1, when a deferred is rejected then it is unresolved. Better call this isPending or something.

comment:9 Changed 10 years ago by timmywil

+1,

comment:10 Changed 10 years ago by dmethvin

Description: modified (diff)

+1, Definitely.

comment:11 Changed 10 years ago by john

Description: modified (diff)

+0, Don't have strong feelings regarding this.

comment:12 Changed 10 years ago by addyosmani

+1

comment:13 Changed 10 years ago by ajpiano

Description: modified (diff)

+1, and we should use the name isUnresolved to maintain the dichotomy

comment:14 Changed 10 years ago by dmethvin

Milestone: 1.next1.7
Priority: lowblocker

comment:15 Changed 10 years ago by jaubourg

Owner: set to jaubourg
Status: openassigned

comment:16 Changed 10 years ago by Jethro Larson

An other possibility: ! def.isResolved()

comment:17 Changed 10 years ago by jaubourg

Resolution: fixed
Status: assignedclosed

It's called isProgressing and is in master.

Related commit: https://github.com/jquery/jquery/commit/a588336a6dcc6f29e870e8fcdd243f96bec5e833

comment:18 Changed 10 years ago by dmethvin

It may be subtle, but I think .isProgressing() has a different implication than .isUnresolved(). The former implies some sort of progress is still being made, whereas the latter just says it's not yet done.

comment:19 in reply to:  18 Changed 10 years ago by jaubourg

Replying to dmethvin:

It may be subtle, but I think .isProgressing() has a different implication than .isUnresolved(). The former implies some sort of progress is still being made, whereas the latter just says it's not yet done.

While .isProgressing() returns true, you can still notify progress (for progress callbacks). I'm just trying to be consistant with the rest of the API:

  • isResolved(): .resolve() has been called
  • isRejected(): .reject() has been called
  • isProgressing(): progress callback can be trigerred

-ed for one-time actions, -ing for repeatable callbacks with an emphase on the callback type.

I'm strictly against isUnresolved, seeing as it is completely misleading (shouldn't it return true when the deferred is rejected?).

comment:20 Changed 9 years ago by dmethvin

Clarifying: The actual resolution in 1.7 was to add a .state to the Deferred. The .isResolved() and .isRejected() methods are deprecated and will be removed in 1.8.

Note: See TracTickets for help on using tickets.