Support (async) generator functions
- Langage dominant
- TypeScript
- Étoiles
- 3.5k
- Forks
- 173
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I think it would be great if the observer pattern described [here](https://threads.js.org/usage-observables) can be written as follows so that we do not have to depend on any observable libraries but ECMAScript standards.
```js
// master.js
import { spawn, Thread, Worker } from "threads"
const counter = await spawn(new Worker("./workers/counter"))
for await (const newCount of counter()) {
console.log(`Counter incremented to:`, newCount)
}
```
```js
// workers/counter.js
import { expose } from "threads/worker"
function* startCounting() { // async generator function should also be OK
for (let currentCount = 1; currentCount <= 10; currentCount++) {
yield currentCount;
}
}
expose(startCounting)
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.