This might be an awful question but I'm trying to use Promise-IO with nodeJS. I'm trying to use the seq function. I have something like the following.
seq = require("promised-io/promise").seq,
var functions= new Array(function1, function2);
seq(functions, startingDataObject)
In function1 I have something like the following.
function function1(startingDataObject) {
var deferred = new Deferred();
when(function3(startingDataObject),
function (returnedData) {
//Some logic
deferred.resolve(returnedData);
},
function (err) {
console.log(err);
throw err;
});
deferred.promise;
}
What i see happening is function2 is getting fired right after deferred.promise. I'm not sure if my google skills are lacking but I don't seem to see many examples on how to use this method. So my question is how do i use Promise-IO to make sync sequential calls.
https://github.com/kriszyp/promised-io#seq
Thanks
Found the issue. I was missing a return deferred.promise in function1. The example above worked perfectly.