Skip to content

Instantly share code, notes, and snippets.

@nooga
Created August 28, 2013 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nooga/6369824 to your computer and use it in GitHub Desktop.
Save nooga/6369824 to your computer and use it in GitHub Desktop.
var q = require('q');
function jednaDroga(p) {
//....
p.resolve(wartosc);
//....
}
function drugaDroga(p) {
//....
p.resolve(123);
//....
}
function zdecyduj() {
var deferred = q.defer();
if(cokolwiek) jednaDroga(deferred);
else drugaDroga(deferred);
return deferred.promise;
}
zdecyduj()
.then(function(wynik) {
//whatever
})
.then(function(){
// etc.
})
.done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment