angular/angular.js — pull request #7214 by jeffwhelpley (2014-04-23 15:52:41+00:00)
Title: Adding .resolve() function to $q

This is a simple, but very useful function missing from the $q library that exists in Q. The typical use case is when you create abstractions where calling code expects a promise to be returned from a given interface. Some implementations of the interface may be asynch (thus why promises are needed), but certain implementations may also be synchronous. You can of course create a deferred, resolve it and return the deferred promise, but simply doing $q.resolve() is much more simple and beautiful. Even if all your existing implementations are asych, this is still useful for a default interface implementation where you just return null, {}, etc.