This repository was archived by the owner on Apr 12, 2024. It is now read-only.
  
  
  
  
  
Description
Type: feature
Reproduces on: any OS, any browser
Code:
https://github.com/angular/angular.js/blob/master/src/ng/q.js#L285
https://github.com/angular/angular.js/blob/master/src/ng/q.js#L460
Solution:
Just send the value as parameter in the callback. It could even have 2 params: success and value (as angularjs callbacks have).
Real use-case:
In our application all messages that are being queued and displayed to the user in a messages-directive are being sent by the server within each structured response (may it be success or error). Our problem is that we have to write something like:
     ajax.call($scope.shared.ajax.getXXX).then(
        function (response) {
          // ...
          msgService.notify(response);
        },
        function (response) {
          msgService.notify(response);
        }
      )
Instead of just
     ajax.call($scope.shared.ajax.getXXX).then(
        function (response) {
          // ...
        }
      ).finally(function(response) {
          msgService.notify(response); 
      });
     // OR JUST
     ajax.call($scope.shared.ajax.getXXX)
       .then(function (response) { // ... })
       .finally(msgService.notify);
CONTEXT:
I am aware that Kris's initial implementation of $q (https://github.com/kriskowal/q) does not have this, but I still believe it's a very good idea to implement. I can contact Kris directly and discuss with him the option to include this in base implementation as well.