Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ジェネレータ関数を使った直接非同期通信
// ジェネレータ関数
const gfn = function * (start, end) {
while(start <= end) {
yield [expect Promise code]
start++
}
}
const g = gfn(1, 10)
const loaded = () => {
const result = g.next();
if (_result.done) {
console.log('complete')
} else {
_result.value.then(data => loaded())
}
loaded()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.