Advertisement
Guest User

promise and generators

a guest
Jan 19th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fetchBla(id) {
  2.     return new Promise(...)
  3. } // Do a query with given ID
  4.  
  5. function *fetchBlas() {
  6.     var index = 1;
  7.     while (true)
  8.         index++;
  9.         yield fetchBla(index);
  10. }
  11.  
  12. let blas = fetchBlas();
  13. blas.next().value.then(...) // Get's stuck in a loop forever .. shouldn't this return a Promise object?..
  14. blas.next().value.then(...) // Blow's up with .then() beeing undefined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement