Created
August 28, 2013 18:55
-
-
Save nooga/6369824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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