title: JS chain promises with result always resolve
body: <p>I am still not 100% solid on how to chain promises.
  Here is what I am trying to achieve:</p>
  
  <p>I have one promise that resolves or rejects, The code further on picks up this and if the promise is resolved it goes on, if rejected it stops (not exactly, but good enough for this question). Now the problem is that I just want to run this promise, without caring if it resolves or rejects. </p>
  
  <p>Way I had it before was simply:</p>
  
  <pre><code>function a(){
      return Service.doSomething();
  }
  </code></pre>
  
  <p>So I wrapped it in other promise and the outcome is:</p>
  
  <pre><code>function a(){
      var q = $q.defer();
      Service.doSomething(); // I don't even need to handle whatever the outcome is
      q.resolve();
      return q.promise;
  }
  </code></pre>
  
  <p>(Yes it is taken from angular project)</p>
  
  <p>Now even thogh this works it just looks pretty ugly. Is there any better/nicer way I can write this?</p>
  
  <p><strong>Update:</strong>
  I do realize that this looks like pretty strange behavior so I am going to explain a bit more.</p>
  
  <p>This example is of angular routes and my custom middleware to handle authentication. </p>
  
  <p>So I have created three "route" handlers: </p>
  
  <ul>
  <li>customRoute</li>
  <li>onlyGuest</li>
  <li>onlyUser</li>
  </ul>
  
  <p>so instead of writing </p>
  
  <pre><code>$routeProvider.route({});
  </code></pre>
  
  <p>I write (for example)</p>
  
  <pre><code>$routeProvider.customRoute({});
  </code></pre>
  
  <p>Now each of those special route handlers extends <em>resolve</em> attribute of route with the authentication. </p>
  
  <p>That way I can do this (for example):</p>
  
  <pre><code>$rootScope.$on('$routeChangeError',function(e, current, previous, rejection){
          // Only for logged in users
          if (rejection &amp;&amp; rejection.needsAuthentication){
              $rootScope.refUrl = $location.path();
              $location.path('/user/login');
          }
  
          // Only for non-logged in users
          if (rejection &amp;&amp; rejection.isOnlyGuest){
              $rootScope.refUrl = $location.path();
              $location.path('/dashboard');
          }
      });
  </code></pre>
  
  <p>Now the onlyGuest and onlyUser should be clear enough, but I also have customRoute() which basically runs the authentication method simply to retrieve user info if user accesses the app directly through this url and can be guest as well as can be logged in. </p>
  
  <p>The problem is that when the authentication method throws reject() the route automatically fires changeError. So for this customRoute() I need to run the authentication but not go to changeError - always resolve as true even if authentication() promise rejects.</p>
  
  <p>Not sure if its any clearer or just got more complicated...</p>