Support for asynchronous iterators (async for of)
See original GitHub issueAsynchronous iterators and generators (aka await for ... of
) are available as part of ES2018.
How can I use it in a react-native app? Currently there is no metro support for them.
Example:
// generator
async function* gen() {
yield 'a';
yield 'b';
return 2;
}
// consumer
try {
for await (const t of gen()) {
console.log(t)
}
}
catch(err) {
console.log("err", err);
}
Any suggestion to workaround the issue is welcome. I could not find anything for using them.
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top Results From Across the Web
for await...of - JavaScript - MDN Web Docs
The for await...of statement creates a loop iterating over async iterable objects as well as sync iterables. This statement can only be used ......
Read more >Async iteration and generators - The Modern JavaScript Tutorial
Asynchronous iteration allow us to iterate over data that comes asynchronously, on-demand. Like, for instance, when we download something ...
Read more >42 Asynchronous iteration - Exploring JS
An Iterator is a factory for iteration results that we retrieve by calling the ... One of the language constructs that supports it...
Read more >Asynchronous Iterators in JavaScript | Codementor
The yield* statement supports delegation to async iterables. var asyncIterable = { [Symbol.asyncIterator]: async function* asyncGenerator() ...
Read more >JavaScript async iterators - Node.js Design Patterns
But what if an object abstracts data generated asynchronously? ... versions of Node.js (Node.js 10.3) introduced support for async iterators ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@berdyshev I was able to figure out what was going wrong. That error is due to an error in the
@babel/plugin-transform-for-of
plugin. It (mistakenly) tries to convertfor await of
statements with the same code asfor of
, and uses the wrong iterator property accessor.I was able to workaround the problem by adding
@babel/plugin-proposal-async-generator-functions
to mybabel.config.js
.@ls-andrew-goodale It is from Generators, which are massively used in SocketCluster to listen and consume events. Mixing all the solutions here proposed, I solved the problem for IOS. For Android, instead, it persits and I can’t figure out why… I add package.json, hoping it could be useful