3

I'm studying some use-case in Deferred, and I came by this instruction:

$.Deferred().reject().promise() 

I don't get it, under what condition we call reject() then directly we call promise()?

I mean, if we want to reject the deferred object, how can the rejected deferred represent a promise?

1 Answer 1

3

When we call .reject() and then .promise(), we are returning a promise that we have already decided will not succeed. Any handlers bound with .fail() or .always() will be immediately invoked upon them being added.

Sign up to request clarification or add additional context in comments.

1 Comment

Does this mean that if we want any handlers bound with .done() to be invoked immediately, we call $.Deferred.resolve().prmoise()?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.