-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Conversation
This would be a valuable addition provided that implementation would be short and wouldn't add too many bytes to the framework. I have found myself recently in a need of something like `always'. Having said this I'm perfectly fine with: LoadingOverlay.start();
Auth.initialize().then(LoadingOverlay.stop, LoadingOverlay.stop); Also we should stick to the naming and semantics used by the original q library: So, I would say - why not - provided that we can have a really concise implementation. Tests and doc updates are mandatory of course. |
I'm also using something like Regarding the naming of the method, I've just found this issue, where a user found out that The solution is to either put the keyword inside a string I've started looking into the test and doc updates, I should push an update soon. |
I have now implemented the full As I mentioned earlier, I have a preference for the name |
This looks good. Can you make sure the following tasks are completed:
|
I think we need a core team member to approve the name "always" over "finally". Other than that can you make sure the other tasks are completed. |
I think "always" is better semantically. To me, this is pretty clear what it does: getPromise().always(doSetup).then(succeed, orFail).always(doCleanup); if you call it finally it doesn't read so well and the order of execution is less clear: getPromise().finally(doSetup).then(succeed, orFail).finally(doCleanup); |
I agree but do @IgorMinar or @mhevery - have a view? |
let's go with |
Added new always(callback) method. Also added tests and updated documentation.
@petebacondarwin, ok great I have now signed the CLA (Laurent C.). I have also squashed the commits into one and updated the commit message to follow the proper format. |
Great! Thanks @laurent22 |
"let's go with always. it reads better and is compatible with all browsers." I can only find a reference to .finally in the docs, what happened? Edit: To anyone with the same doubt: f078762 |
The current implementation of
$q
doesn't support the always() method. This is a very useful method since it can avoid creating duplicate code when you do not care about the outcome of a promise. Here's some sample code:With an
always
method it could be simplified to just this:The proposed implementation is to add an
always()
method to thepromise
object. This method simply re-uses the existingthen()
method, which means it won't bloat the$q
implementation.If there's any interest in this implementation, I'd be glad to add the tests for it.