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:
---------
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