forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmutations.ts
More file actions
59 lines (52 loc) · 1.29 KB
/
mutations.ts
File metadata and controls
59 lines (52 loc) · 1.29 KB
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
53
54
55
56
57
58
59
export default (ts) =>
ts
? [
{
fileName: 'app/mutations.js',
code: `
import { Mutate } from 'overmind'
export const setValue: Mutate = state =>
state.value = 'foo'
export const setValueFromAction: Mutate<string> = (state, value) =>
state.value2 = value
export const setValueFromState: Mutate = state =>
state.value3 = state.value
`,
},
{
fileName: 'app/actions.js',
code: `
import { Action } from 'overmind'
import * as mutations from './mutations'
export const setValues: Action<string> = action =>
action
.mutate(mutations.setValue)
.mutate(mutations.setValueFromAction)
.mutate(mutations.setValueFromState)
`,
},
]
: [
{
fileName: 'app/mutations.js',
code: `
export const setValue = state =>
state.value = 'foo'
export const setValueFromAction = (state, value) =>
state.value2 = value
export const setValueFromState = state =>
state.value3 = state.value
`,
},
{
fileName: 'app/actions.js',
code: `
import * as mutations from './mutations'
export const setValues = action =>
action
.mutate(mutations.setValue)
.mutate(mutations.setValueFromAction)
.mutate(mutations.setValueFromState)
`,
},
]