Bug Tracker

Ticket #8856 (closed enhancement: fixed)

Opened 4 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

Description (last modified by ajpiano) (diff)

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

comment:1 Changed 4 years ago by timmywil

  • Priority changed from undecided to low
  • Component changed from unfiled to deferred

comment:2 Changed 4 years ago by john

Let's consider this for 1.7.

comment:3 Changed 4 years ago by timmywil

  • Status changed from new to open
  • Milestone changed from 1.next to 1.7

comment:4 Changed 4 years ago by jaubourg

I'd vote for isPending()

comment:5 Changed 4 years ago by john

  • Milestone changed from 1.7 to 1.next

comment:6 Changed 3 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:7 Changed 3 years ago by rwaldron

  • Description modified (diff)

+1,

comment:8 Changed 3 years ago by jaubourg

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

comment:9 Changed 3 years ago by timmywil

+1,

comment:10 Changed 3 years ago by dmethvin

  • Description modified (diff)

+1, Definitely.

comment:11 Changed 3 years ago by john

  • Description modified (diff)

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

comment:12 Changed 3 years ago by addyosmani

+1

comment:13 Changed 3 years ago by ajpiano

  • Description modified (diff)

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

comment:14 Changed 3 years ago by dmethvin

  • Priority changed from low to blocker
  • Milestone changed from 1.next to 1.7

comment:15 Changed 3 years ago by jaubourg

  • Owner set to jaubourg
  • Status changed from open to assigned

comment:16 Changed 3 years ago by Jethro Larson

An other possibility: ! def.isResolved()

comment:17 Changed 3 years ago by jaubourg

  • Status changed from assigned to closed
  • Resolution set to fixed

It's called isProgressing and is in master.

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

comment:18 follow-up: ↓ 19 Changed 3 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 3 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 2 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.