-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-mst-1.ts
46 lines (35 loc) · 947 Bytes
/
test-mst-1.ts
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
import { types, onSnapshot, getSnapshot } from "mobx-state-tree"
const Todo = types.model("Todo", {
title: types.string,
description: types.string,
when: types.string
}).actions(self => ({
}))
//let x = Todo.create({})
let x1 = Todo.create({
title: "Aaron",
description: "Test Description",
when: new Date() + ""
})
console.log(getSnapshot(x1))
const TodoStore = types.model("Todo", {
todos: types.optional(types.array(Todo), [])
}).actions(self => ({
addItem(_value: typeof Todo.Type) {
self.todos.push(Todo.create(_value))
}
}))
// will generate the same error..
let theStore = TodoStore.create({})
console.log(getSnapshot(theStore))
theStore.addItem({
title: "Aaron",
description: "Test Description",
when: new Date() + ""
})
theStore.addItem({
title: "Andrea",
description: "Test Description for Andrea",
when: new Date() + ""
})
console.log(getSnapshot(theStore))