Side navigation
#13717 closed feature (plugin)
Opened April 03, 2013 02:34AM UTC
Closed March 01, 2014 10:20PM UTC
$.Deferred helper methods to resolve/reject
Reported by: | danheberden | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | deferred | Version: | 2.0b2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
TL;DR the only way to change a failure to a resolution and vice-versa is to return a new promise. This is different from the promises/A spec (for good reason, I feel) but still is cumbersome to work with. I propose either:
$.Deferred.resolve(value); // returns a new, done promise with value $.Deferred.reject(value); // returns a new, failed promise with value
OR
since $.when already does this for synchronous content, create
$.unless that takes any number args and only succeeds if all of them fail.
For details, implementation examples, and a fun time check out http://jsfiddle.net/danheberden/jhXAp/
xoxo,
Dan
Attachments (0)
Change History (5)
Changed April 03, 2013 10:38AM UTC by comment:1
Changed April 03, 2013 04:53PM UTC by comment:2
Any thoughts on $.unless, jaubourg?
Changed April 03, 2013 04:56PM UTC by comment:3
Also, my mistake for not noticing then would work with a deferred and not just a promise, so $.Deferred().resolve(value) would be ok, albeit still a bit verbose.
Changed April 22, 2013 04:17PM UTC by comment:4
component: | unfiled → deferred |
---|---|
priority: | undecided → low |
status: | new → open |
Changed March 01, 2014 10:20PM UTC by comment:5
resolution: | → plugin |
---|---|
status: | open → closed |
I don't think we are looking to add features, let's focus on Promise and see how we can integrate it. This can be done as a plugin if desired.
On my own projects, I have something as follows:
Not sure if they should be in core but we could use some Deferred-related plugins for sure.
Not a fan of
$.Deferred.resolve
, I don't see the gain compared to$.Deferred().resolve
.