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
56 lines (47 loc) · 1002 Bytes
/
mutations.ts
File metadata and controls
56 lines (47 loc) · 1002 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
53
54
55
56
export const js = [
{
fileName: 'app/state.js',
code: `
export let isLoadingPosts = false
export let posts = []
`,
},
{
fileName: 'app/mutations.js',
code: `
export const setLoadingPosts = state =>
state.isLoadingPosts = true
export const unsetLoadingPosts = state =>
state.isLoadingPosts = false
export const setPosts = (state, posts) =>
state.posts = posts
`,
},
]
export const ts = [
{
fileName: 'app/state.ts',
code: `
export type Post {
id: number
title: string
body: string
}
export let isLoadingPosts: boolean = false
export let posts: Post[] = []
`,
},
{
fileName: 'app/mutations.ts',
code: `
import { Mutation } from 'overmind'
import { Post } from './state'
export const setLoadingPosts: Mutation = state =>
state.isLoadingPosts = true
export const unsetLoadingPosts: Mutation = state =>
state.isLoadingPosts = false
export const setPosts: Mutation<Post[]> = (state, posts) =>
state.posts = posts
`,
},
]