Skip to content

Commit a26615a

Browse files
docs(website): update to latest API changes with operator factories
1 parent 2ac7dc2 commit a26615a

File tree

24 files changed

+158
-108
lines changed

24 files changed

+158
-108
lines changed

packages/overmind-website/api/action.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ Actions are defined with a powerful chaining API which gives control of the exec
1010

1111
The action is built up by **operators**, methods called on the action itself. These operators describes the execution logic.
1212

13+
## attempt
14+
```marksy
15+
h(Example, { name: "api/action_try" })
16+
```
17+
18+
Typically used to explicitly handle potentially thrown errors from an effect.
19+
20+
The first argument is a function that receives the **effects** registered in the application as the first argument, and the current **value** as the second argument. The second argument to the operator are two paths, **success** and **error** which are respectively executed based on the success of the first argument function.
21+
1322
## compose
1423
```marksy
1524
h(Example, { name: "api/action_compose" })
@@ -26,15 +35,6 @@ Typically used to only continue execution of the last action call if multiple ac
2635

2736
The only argument is the time limit in milliseconds the operator should prevent action calls to continue. When the an action call has waited for the milliseconds defined, without any new action calls has been made, the execution will continue.
2837

29-
## do
30-
```marksy
31-
h(Example, { name: "api/action_do" })
32-
```
33-
34-
Typically used to fire off an effect without caring about its returned result, if any.
35-
36-
Only argument is a function that receives the **effects** registered in the application as the first argument, and the current **value** of the action as the second argument. Any returned value will be ignored, though you can return a promise to indicate that the do operator needs to be resolved. The current value of the action will be passed to the next operator.
37-
3838
## filter
3939
```marksy
4040
h(Example, { name: "api/action_filter" })
@@ -52,6 +52,15 @@ Typically used to fork out execution when a value can result in multiple complex
5252

5353
The first argument is a function that receives the **effects** as the first argument and the current **value** as the second. The function is expected to return a value, either synchronously or asynchronously, that matches the paths passed as the second argument to the fork operator.
5454

55+
## run
56+
```marksy
57+
h(Example, { name: "api/action_do" })
58+
```
59+
60+
Typically used to fire off an effect without caring about its returned result, if any.
61+
62+
Only argument is a function that receives the **effects** registered in the application as the first argument, and the current **value** of the action as the second argument. Any returned value will be ignored, though you can return a promise to indicate that the do operator needs to be resolved. The current value of the action will be passed to the next operator.
63+
5564

5665
## map
5766
```marksy
@@ -80,15 +89,6 @@ Typically used to run multiple composed actions in parallel. "In parallel" means
8089

8190
The parallel operator does not return a value.
8291

83-
## try
84-
```marksy
85-
h(Example, { name: "api/action_try" })
86-
```
87-
88-
Typically used to explicitly handle potentially thrown errors from an effect.
89-
90-
The first argument is a function that receives the **effects** registered in the application as the first argument, and the current **value** as the second argument. The second argument to the operator are two paths, **success** and **error** which are respectively executed based on the success of the first argument function.
91-
9292
## when
9393
```marksy
9494
h(Example, { name: "api/action_when" })

packages/overmind-website/examples/api/action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default (ts) =>
66
import { Action } from 'overmind'
77
88
export const doThis: Action<number> = action =>
9-
action()
9+
action
1010
.map(operations.getUser)
1111
.mutate(mutations.setUser)
1212
`,
@@ -16,7 +16,7 @@ export const doThis: Action<number> = action =>
1616
{
1717
code: `
1818
export const doThis = action =>
19-
action()
19+
action
2020
.map(operations.getUser)
2121
.mutate(mutations.setUser)
2222
`,

packages/overmind-website/examples/api/action_compose.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export default (ts) =>
77
import * as operations from './operations'
88
99
export const goDoSomethingWithString: Action<string> = action =>
10-
action()
10+
action
1111
1212
export const doThis: Action<string> = action =>
13-
action()
13+
action
1414
.map(operations.transformString)
1515
.compose(goDoSomethingWithString)
1616
`,
@@ -23,10 +23,10 @@ export const doThis: Action<string> = action =>
2323
import * as operations from './operations'
2424
2525
export const goDoSomethingWithString = action =>
26-
action()
26+
action
2727
2828
export const doThis = action =>
29-
action()
29+
action
3030
.map(operations.transformString)
3131
.compose(goDoSomethingWithString)
3232
`,

packages/overmind-website/examples/api/action_debounce.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default (ts) =>
66
import { Action } from 'overmind'
77
88
export const doThis: Action = action =>
9-
action()
9+
action
1010
.debounce(200)
1111
`,
1212
},
@@ -15,7 +15,7 @@ export const doThis: Action = action =>
1515
{
1616
code: `
1717
export const doThis = action =>
18-
action()
18+
action
1919
.debounce(200)
2020
`,
2121
},

packages/overmind-website/examples/api/action_do.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default (ts) =>
66
code: `
77
import { Operation } from 'overmind'
88
9-
export const trackSubmitForm: Operation.Do = ({ track }) =>
9+
export const trackSubmitForm: Operation.Run = ({ track }) =>
1010
track.interaction('submitForm')
1111
`,
1212
},
@@ -16,8 +16,8 @@ export const trackSubmitForm: Operation.Do = ({ track }) =>
1616
import { Action } from 'overmind'
1717
1818
export const doThis: Action = action =>
19-
action()
20-
.do(operations.trackSubmitForm)
19+
action
20+
.run(operations.trackSubmitForm)
2121
`,
2222
},
2323
]
@@ -33,8 +33,8 @@ export const trackSubmitForm = ({ track }) =>
3333
fileName: 'app/actions.js',
3434
code: `
3535
export const doThis = action =>
36-
action()
37-
.do(operations.trackSubmitForm)
36+
action
37+
.run(operations.trackSubmitForm)
3838
`,
3939
},
4040
]

packages/overmind-website/examples/api/action_filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const isGreatherThan2: Operation.Filter<string> = (_, value) =>
1919
import { Action } from 'overmind'
2020
2121
export const doThis: Action<string> = action =>
22-
action()
22+
action
2323
.filter(operations.isOnline)
2424
.filter(operations.isGreaterThan2)
2525
`,
@@ -40,7 +40,7 @@ export const isGreaterThan2 = (_, value) =>
4040
fileName: 'app/actions.js',
4141
code: `
4242
export const doThis = action =>
43-
action()
43+
action
4444
.filter(operations.isOnline)
4545
.filter(operations.isGreaterThan2)
4646
`,

packages/overmind-website/examples/api/action_fork.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ export const getUserRole: Operation.Fork = ({ state }) =>
1515
code: `
1616
import { Action } from 'overmind'
1717
18-
export const adminAction: Action = action => action()
18+
export const adminAction: Action = action => action
1919
20-
export const superuserAction: Action = action => action()
20+
export const superuserAction: Action = action => action
2121
22-
export const userAction: Action = action => action()
22+
export const userAction: Action = action => action
2323
2424
export const doThis: Action = action =>
25-
action()
25+
action
2626
.fork(operations.getUserRole, {
2727
admin: adminAction,
2828
superuser: superuserAction,
@@ -42,14 +42,14 @@ export const getUserRole = ({ state }) =>
4242
{
4343
fileName: 'app/actions.js',
4444
code: `
45-
export const adminAction = action => action()
45+
export const adminAction = action => action
4646
47-
export const superuserAction = action => action()
47+
export const superuserAction = action => action
4848
49-
export const userAction = action => action()
49+
export const userAction = action => action
5050
5151
export const doThis = action =>
52-
action()
52+
action
5353
.fork(operations.getUserRole, {
5454
admin: adminAction,
5555
superuser: superuserAction,

packages/overmind-website/examples/api/action_map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const trim: Operation.Map<string, string> =
1919
import { Action } from 'overmind'
2020
2121
export const doThis: Action<string> = action =>
22-
action()
22+
action
2323
.map(operations.trim)
2424
.map(operations.getUser)
2525
`,
@@ -40,7 +40,7 @@ export const trim = (_, value) =>
4040
fileName: 'app/actions.js',
4141
code: `
4242
export const doThis = action =>
43-
action()
43+
action
4444
.map(operations.trim)
4545
.map(operations.getUser)
4646
`,

packages/overmind-website/examples/api/action_mutation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const setInputValue: Mutate<string> = (state, value) =>
1919
import { Action } from 'overmind'
2020
2121
export const doThis: Action<string> = action =>
22-
action()
22+
action
2323
.mutate(mutations.setLoading)
2424
.mutate(mutations.setInputValue)
2525
`,
@@ -40,7 +40,7 @@ export const setInputValue = (state, value) =>
4040
fileName: 'app/actions.js',
4141
code: `
4242
export const doThis = action =>
43-
action()
43+
action
4444
.mutate(mutations.setLoading)
4545
.mutate(mutations.setInputValue)
4646
`,

packages/overmind-website/examples/api/action_parallel.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export default (ts) =>
55
fileName: 'app/actions.ts',
66
code: `
77
export const goDoSomething: Action<any> = action =>
8-
action()
8+
action
99
1010
export const goDoSomethingElse: Action<string> = action =>
11-
action()
11+
action
1212
1313
export const doThis: Action<string> = action =>
14-
action()
14+
action
1515
.parallel([
1616
goDoSomething,
1717
goDoSomethingElse
@@ -24,13 +24,13 @@ export const doThis: Action<string> = action =>
2424
fileName: 'app/actions.js',
2525
code: `
2626
export const goDoSomething = action =>
27-
action()
27+
action
2828
2929
export const goDoSomethingElse = action =>
30-
action()
30+
action
3131
3232
export const doThis = action =>
33-
action()
33+
action
3434
.parallel([
3535
goDoSomething,
3636
goDoSomethingElse

0 commit comments

Comments
 (0)