Last active
August 29, 2015 14:13
-
-
Save nathankleyn/0b0c75bd549220c3eb6b to your computer and use it in GitHub Desktop.
An example of JavaScript generators.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *asyncThing1() { | |
someAsyncFn(function(val) { | |
yield val; | |
}); | |
} | |
function *asyncThing2(arg) { | |
someOtherAsyncFn(arg, function(val) { | |
yield val; | |
}); | |
} | |
function *asyncThing3(arg) { | |
someOtherAgainAsyncFn(arg, function(val) { | |
yield val; | |
}); | |
} | |
var result = asyncThing1().next(), | |
result2 = asyncThing2(result).next(), | |
result3 = asyncThing3(result2).next(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment