I'm exploring the ES6 generator in combination with Angular's $http service on the client side. My goal is to utilize the $http service without relying on callbacks, if achievable. For example:
var gen = function* () {
var test = yield $http.get('/test/');
console.log(test);
};
var http = gen();
http.next();
http.next(); // returns undefined
/// or ///
var gen = function* () {
yield $http.get('/test/');
};
console.log(http.next()); //returns a promise object which won't allow me to use the needed data
The motivation behind my inquiry is to replicate a presentation demonstrated here https://youtu.be/QO07THdLWQo?t=4m58s
I am seeking the most straightforward and uncomplicated approach. Any recommendations?