-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A problem proposal: fullfilling rejections #60
Comments
Just experimenting and forgot a simpler way: changing the return line with just PD: just using |
Hmm I haven't thought about that. I guess this is a pretty good idea, even though your implementation is a bit odd looking :) |
That's the comment for. So simplifying a little: var Q = require('q');
var deferred = Q.defer();
var promise = deferred.promise;
var promise2 = promise.catch(function savior(rejection) {
console.log("Im the savior, who received: " + rejection);
return "A saved rejection";
});
promise2.then(function(value) {
console.log("The promise 2 was fullfilled with: " + value);
}, function(reason) {
console.log("The promise 2 was rejected with: " + reason);
});
deferred.reject("A rejection reason"); |
Yep. There have been a lot of changes done to promise-it-wont-hurt recently: #46 (comment). I will take this as one of my TODOs. On a side note, it would really help us if you could find time to translate (or to correct) a few strings into Spanish: https://github.com/stevekane/promise-it-wont-hurt/blob/master/i18n/es.json I'm still learning Spanish and unfortunately my accent and vocabulary is distinctively estadounidense :) |
I could do something about it the wednesday or the weekend to feel helpful ;) |
Oh what the heck, I peeked at it, seemed easy, and I just did it on #62 |
Hi. I was just working with
mongodb
and I sidetracked to thinking on promises and understanding a little more of them. After having solved this workshop (which was great), I was tinkering with a concept on the Promises/A+ spec that we can add as a new exercise. Consider the following code snippet.The output of this program would be
So, I think the magic to show on this program is in receiving a rejected promise (the
promise
promise) and then making it'sthen
method return a fullfilled promise (thepromise2
promise) with the usage of returning thenables. Somehow the curiosity got me high this night to think on this kind of things (hey, a rime).A problem on exercising this concept should be a nice addition.
The text was updated successfully, but these errors were encountered: