Wednesday, February 13, 2019

ES6 - Chaining functions using Generator Function

Chaining functions using Generator Function

function* doSomething2() {
  yield* [
    () => {
      console.log("hello2");
      gen2.next();
      gen2.next().value();
     },
    () => {
      console.log("world2");
    },
    () => {
      console.log("world22");
    },
  ];
}

var gen2 = doSomething2();

gen2.next().value();


Output:
---------
hello2
world22

No comments:

Post a Comment

Followers

Blog Archive