-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$q .always() Implementation #1828
Comments
+1 The upstream q package calls this .fin() |
Is this issue a duplicate of #1378, if so can we move discussion there and close this one maybe? 👍 |
They're different. The .fin() method is supposed to be like a finally block. The .end() method is a mechanism to say I'm done with this, if I missed something please treat it as an unhandled exception (log it, use $exceptionHandler, incite a riot). |
Oops, my bad. As you were :)
|
+1 |
duplicate of #2424? |
Does this make sense with promise chaining? promise.then(callback).always(callback).then(callback again?) |
Yes. It is semantically equivalent to simply providing the same handler for Pete
|
Provided that callback has no dependencies on what information it receives, On Wed, May 8, 2013 at 9:16 AM, Pete Bacon Darwin
|
An always/finally callback receives no arguments and it resolves to same as the original promise unless it rejects. // Resolves to 5
$q.when(5).always(function() { return 7 });
// Resolves to 5 after 1 second
$q.when(5).always(q.delay(1000) { return 7 });
// Rejects with Error: nowayjose
$q.when(5).always(function() { throw new Error('nowayjose') }); See https://github.com/kriskowal/q/wiki/API-Reference#promisefinallycallback. |
I know the goal is to keep $q lightweight, but any interest in an 'always' callback facility? Either an additional arg in .then()
Or something like:
The text was updated successfully, but these errors were encountered: