repos / starfx

supercharged async flow control library.
git clone https://github.com/neurosnap/starfx.git

commit
61543a3
parent
a80c485
author
Eric Bower
date
2023-08-28 15:55:22 +0000 UTC
doc: readme
1 files changed,  +4, -2
M README.md
+4, -2
 1@@ -18,7 +18,7 @@ Supercharged async flow control library.
 2 ## example
 3 
 4 ```ts
 5-import { json, parallel, request, run } from "starfx";
 6+import { json, main, parallel, request } from "starfx";
 7 
 8 function* fetchMovie(title: string) {
 9   const response = yield* request(`/movies/${title}`);
10@@ -26,11 +26,13 @@ function* fetchMovie(title: string) {
11   return data;
12 }
13 
14-const task = run(function* () {
15+const task = main(function* () {
16   const movies = ["titanic", "avatar", "good will hunting"];
17   const ops = movies.map((title) => () => fetchMovie(title));
18+
19   // parallel returns a list of `Result` type
20   const group = yield* parallel(ops);
21+  // wait for results
22   const results = yield* group;
23   return results;
24 });