I want the sequence of execution to be as follows. 1. unattach(x) 2. updateLists(y) 3. console.log("completed execution of function update")
Only after both the functions (unattach & updateLists) have completed execution then the update function should return. The problem is I am not able to make it wait for both functions to complete execution. Is there something wrong in the return statement ?
function main()
{
when(update).then(function(){
console.log("completed execution of function update");
});
}
function update()
{
return when(function(){
unattach(x);
}).then(function(){
updateLists(y);
});
}