Delayed object-deferred.state()

Delayed object-deferred.state(), someone asked me to explain?


Determine the current state of a Deferred object .

The deferred.state() method returns a string representing the current state of the Deferred object. A Deferred object can be in one of three states:

  • Pending : The Deferred object is not yet completed (not "rejected" or "resolved").
  • The resolved : Deferred object is in the resolved state, which means that deferred.resolve()  or  deferred.resolveWith() is accessed by the object and doneCallbacks (or in the process being called).
  • Rejected : the state of the Deferred object is rejected, which means that, deferred.reject ()  or  deferred.rejectWith ()  is Object Access and failCallbacks be accessed (or in the process of being called in).

This method is mainly useful for debugging to determine, for example, whether deferral has been resolved even if you intend to reject its internal code.

Post your comments / questions