forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction_fork.ts
More file actions
55 lines (48 loc) · 1.07 KB
/
action_fork.ts
File metadata and controls
55 lines (48 loc) · 1.07 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
export const js = [
{
fileName: 'operations.js',
code: `
export const getUserRole = ({ state }) =>
state.user.role
`,
},
{
fileName: 'actions.js',
code: `
export const adminAction = action => action()
export const superuserAction = action => action()
export const userAction = action => action()
export const doThis = action =>
action()
.fork(operations.getUserRole, {
admin: adminAction(action),
superuser: superuserAction(action),
user: userAction(action)
})
`,
},
]
export const ts = [
{
fileName: 'operations.js',
code: `
export const getUserRole: Fork = ({ state }) =>
state.user.role
`,
},
{
fileName: 'actions.js',
code: `
export const adminAction: Action = action => action()
export const superuserAction: Action = action => action()
export const userAction: Action = action => action()
export const doThis: Action = action =>
action()
.fork(operations.getUserRole, {
admin: adminAction(action),
superuser: superuserAction(action),
user: userAction(action)
})
`,
},
]