q.js : Is it possible to know if a promise has resolved/rejected or not

phani picture phani · Nov 20, 2014 · Viewed 7.4k times · Source

In my scenario I return a promise when I'm making a request.

In the end I resolve/reject the deferred obj.

I want to reuse the promise if it hasn't been resolved/rejected.

Any info would be useful.

Answer

phani picture phani · Nov 20, 2014

I got the answer by looking into q.js source.

deferred.promise.inspect().state

This will return the state of the promise.

returns "fulfilled" if it was resolved or fulfilled
returns "rejected" if it was rejected
returns "pending" if it hasn't been resolved or rejected