This package is no longer supported.
ng-q-plus is an angular module enhancing $q promises with additional features
require('angular').module 'app', [require('ng-q-plus')]
.service 'myService', ['$q', ($q) ->
getPkmn = (i) -> $q.resolve { id: i, name: "Some gibberish name" }
getDesc = (i) -> $q.resolve "This is pokemon " + i
pokemons = $q.resolve [1..150]
.map (i) ->
getPkmn(i).set 'description', getDesc(i)
.timeout 1000, "Uh oh, it took longer than 1 second to catch 'em all"
.then (list) ->
console.log JSON.stringify list, null, 2
# Will print out
# [
# { id: 1, name: "Some gibberisch name", description "This is pokemon 1" }
# { id: 2, name: "Some gibberisch name", description "This is pokemon 2" }
# ...
# { id: 150, name: "Some gibberisch name", description "This is pokemon 150" }
# ]
]
The module should be available via unpkg at https://unpkg.com/ng-q-plus
No guarantees for uptime or anything like that, though.
The module can be required via browserify require, as an AMD module via requirejs or as a global, if window.angular is
present. It creates the angular module 'ng-q-plus' and exports its name. This module augments the existing
$q
service, it does not create a service of its own.
Each promise gets the new methods as defined in the ExtendedPromise class which can be found in the documentation.