I'm using the RSVP.js lib in a browser.
I have one promise applicationReady
I have another promise loadSomeData
I have a final promise, configureUI
Each relies on the previous promise to do it's work. How do I get these three promises to run in series? I'm clearly missing something.
Thanks!
SOLUTION:
Ok, here's the answer:
Does not work:
applicationReady
.then(loadSomeData)
.then(configureUI)
Does work:
applicationReady
.then(function() { return loadSomeData; })
.then(function() { return configureUI; })
There is a difference between a promise and a function that returns a promise. Bummer that then()
doesn't figure this out itself. What's the usecase for then(promise) ?
Ok, here's the answer:
Does not work:
applicationReady
.then(loadSomeData) // loadSomeData is a promise
.then(configureUI) // configureUI is a promise
Does work:
applicationReady
.then(function() { return loadSomeData; })
.then(function() { return configureUI; })
There is a difference between a promise and a function that returns a promise.