Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmihal/generator-method
Meteor package to support methods that yield multiple times.
https://github.com/dmihal/generator-method
meteor meteorjs
Last synced: 23 days ago
JSON representation
Meteor package to support methods that yield multiple times.
- Host: GitHub
- URL: https://github.com/dmihal/generator-method
- Owner: dmihal
- Created: 2018-07-07T10:46:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-17T15:08:22.000Z (over 5 years ago)
- Last Synced: 2024-10-04T10:41:33.591Z (about 1 month ago)
- Topics: meteor, meteorjs
- Language: JavaScript
- Homepage: https://atmospherejs.com/dmihal/generator-method
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# generator-method
## Install
```
meteor add dmihal:generator-method
```## Example
### Server:
```javascript
Meteor.generatorMethod('test', async function* test() {
yield { status: 'start' };
await wait(1);
yield { status: 'running', stage: 1 };
await wait(1);
yield { status: 'running', stage: 2 };
await wait(1);
yield { status: 'running', stage: 3 };
await wait(1);
yield { status: 'done' };
});function wait(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
```### Client:
```javascript
async runSomeMethod() {
const handle = Meteor.callGenerator('test');for await (const response of handle) {
console.log(response);
}
}
```