We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Think it would be useful if you could implement some like throat so you could specify how many parallel yields is possible
consider this example
co(function* (){ const book = fetch("books/mobidick") const chapters = book.chapters let pages = [] // use 5 paralle http request at the same time yield co(5, function* { for(chapter of chapters){ let page = yield fetch("books/mobidick/chapters/" + chapter.index) pages[chapter.index] = page } }) return pages })
The text was updated successfully, but these errors were encountered:
That's not possible, really. The idea is that the value that yield returns is resolved and the code continues to execute synchronously.
For parallel requests you need to yield an array (or object) with promises, so your example can be this:
co(function* (){ const book = fetch("books/mobidick") const chapters = book.chapters let pages = [] chapters.forEach((chapter) => { pages[chapter.index] = fetch("books/mobidick/chapters/" + chapter.index); }); return yield pages; });
Sorry, something went wrong.
No branches or pull requests
Think it would be useful if you could implement some like throat so you could specify how many parallel yields is possible
consider this example
The text was updated successfully, but these errors were encountered: