Skip to content

Commit 176cc0d

Browse files
docs(website): add parallel docs
1 parent 9d001d7 commit 176cc0d

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

packages/overmind-website/api/operators.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ You are only allowed to change the state in the mutate operator.
5656
h(Example, { name: "api/operators_operator_mutate" })
5757
```
5858

59+
## parallel
60+
Will run every operator and wait for all of them to finish before moving on. Works like *Promise.all*.
61+
62+
```marksy
63+
h(Example, { name: "api/operators_operator_parallel" })
64+
```
65+
5966
## pipe
6067
The pipe is an operator in itself. Use it to compose other operators and pipes.
6168

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export default (ts) =>
2+
ts
3+
? [
4+
{
5+
code: `
6+
import { Operator, pipe, mutate } from 'overmind'
7+
import { Item } from './state'
8+
9+
export const loadSomeData: Operator<void, void> = pipe(...)
10+
export const loadSomeMoreData: Operator<void, void> = pipe(...)
11+
export const manageAllData = mutate(...)
12+
13+
export const openItem: Operator<void, void> = pipe(
14+
parallel([
15+
loadSomeData,
16+
loadSomeMoreData
17+
]),
18+
manageAllData
19+
)
20+
`,
21+
},
22+
]
23+
: [
24+
{
25+
code: `
26+
import { pipe, mutate } from 'overmind'
27+
28+
export const loadSomeData = pipe(...)
29+
export const loadSomeMoreData = pipe(...)
30+
export const manageAllData = mutate(...)
31+
32+
export const openItem = pipe(
33+
parallel([
34+
loadSomeData,
35+
loadSomeMoreData
36+
]),
37+
manageAllData
38+
)
39+
`,
40+
},
41+
]

0 commit comments

Comments
 (0)