Tuesday, November 5, 2013

When a function returns a promise.

var foo = iReturnPromise(bar, baz);
var qux = iDoSomethingElse(foo);

 
 

...will not work! (assuming iDoSomethingElse expects an object and not a promise) Instead, the way to skin this cat is...

 
 

var fooPromise = iReturnPromise(bar, baz);
fooPromise.then(function(foo) {
   var qux = iDoSomethingElse(foo);
});

No comments:

Post a Comment