Your statement does nothing more than ask the interpreter to assign the value returned from
then() to the
then() returns you a Promise (as you can see here: https://github.com/angular/angular.js/blob/master/src/ng/q.js#L283). You could picture this by seeing that the Promise (a simple object) is being pulled out of the function and getting assigned to
vm.feed. This happens as soon as the interpreter executes that line.
Since your successful callback does not run when you call
then() but only when your promise gets resolved (at a later time, asynchronously) it would be impossible for
A nice introduction to the topic is available at: https://www.youtube.com/watch?v=lil4YCCXRYc
To use it right now you can transpile your code through Babel: https://babeljs.io/docs/usage/experimental/ (by running with
You can also see some examples here: https://github.com/lukehoban/ecmascript-asyncawait.
~ Answered on 2015-07-07 09:12:01