forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators_operator_catcherror.ts
More file actions
52 lines (48 loc) · 992 Bytes
/
operators_operator_catcherror.ts
File metadata and controls
52 lines (48 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
export default (ts) =>
ts
? [
{
fileName: 'actions.ts',
code: `
import { Operator, pipe, mutate, catchError } from 'overmind'
export const doSomething: Operator<string> = pipe(
mutate(() => {
throw new Error('foo')
}),
mutate(() => {
// This one is skipped
})
catchError(({ state }, error) => {
state.error = error.message
return 'value_to_be_passed_on'
}),
mutate(() => {
// This one continues executing with replaced value
})
)
`,
},
]
: [
{
fileName: 'actions.js',
code: `
import { pipe, mutate, catchError } from 'overmind'
export const doSomething = pipe(
mutate(() => {
throw new Error('foo')
}),
mutate(() => {
// This one is skipped
})
catchError(({ state }, error) => {
state.error = error.message
return 'value_to_be_passed_on'
}),
mutate(() => {
// This one continues executing with replaced value
})
)
`,
},
]