- commit
- 0cba72f
- parent
- a57267b
- author
- Eric Bower
- date
- 2023-07-14 15:40:16 +0000 UTC
docs: quick readme example
1 files changed,
+23,
-0
+23,
-0
1@@ -13,6 +13,29 @@ Supercharged async flow control library.
2 - side-effect system for `redux`
3 - data synchronization and caching for `react` and `redux`
4
5+## example
6+
7+```ts
8+import { run, parallel, request, json } from 'starfx';
9+
10+function* fetchMovie(title: string) {
11+ const response = yield* request(`/movies/${title}`);
12+ const data = yield* json(response);
13+ return data;
14+}
15+
16+const task = run(function*() {
17+ const movies = ['titanic', 'avatar', 'good will hunting'];
18+ const ops = movies.map((title) => () => fetchMovie(title));
19+ const group = yield* parallel(ops);
20+ const results = yield* group;
21+ return results;
22+});
23+
24+const results = await task;
25+console.log(results);
26+```
27+
28 ## usage
29
30 Please see [examples repo](https://github.com/neurosnap/starfx-examples).