since it it not possible to create a arrow generator function, yield is never used in the context of a arrow function.
var arrowGenerator = *() => { };
then you should be able to and use yield in the context of the generator function. just like this
function* generator() {
funcWithCallback((value) => {
yield value;
});
}
but in babel it uses yield in context of the arrow function and not the genreators.
i want to do this so you don't need to return a callback function with the value, just to yield it.
function* gen() {
yield function (callback) {
funcWithCallback(callback);
}
}
The
yield
andyield*
keywords can only be used directly inside a generator function. Your code fragment is conceptually flawed in a similar manner to:or, to this:
Obviously, these 2 examples don't "work", and so does your code fragment.