forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction_mutation.ts
More file actions
48 lines (44 loc) · 1000 Bytes
/
action_mutation.ts
File metadata and controls
48 lines (44 loc) · 1000 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
export default (ts) =>
ts
? [
{
fileName: 'app/mutations.ts',
code: `
import { Mutate } from 'overmind'
export const setLoading: Mutate = state =>
state.isLoading = true
export const setInputValue: Mutate<string> = (state, value) =>
state.inputValue = value
`,
},
{
fileName: 'app/actions.ts',
code: `
import { Action } from 'overmind'
export const doThis: Action<string> = action =>
action
.mutate(mutations.setLoading)
.mutate(mutations.setInputValue)
`,
},
]
: [
{
fileName: 'app/mutations.js',
code: `
export const setLoading = state =>
state.isLoading = true
export const setInputValue = (state, value) =>
state.inputValue = value
`,
},
{
fileName: 'app/actions.js',
code: `
export const doThis = action =>
action
.mutate(mutations.setLoading)
.mutate(mutations.setInputValue)
`,
},
]