-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
39 lines (32 loc) · 852 Bytes
/
index.js
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
import { observable, computed } from 'mobx';
import { Provider } from 'mobx-react';
import * as React from 'react';
import ReactDOM from 'react-dom';
import TodoListView from "./TodoListView.js";
import registerServiceWorker from "./registerServiceWorker";
import "./index.css";
const todoStore = title => {
return {
@observable title: title,
@observable finished: false,
id: Math.random()
};
};
const todoListStore = {
@observable todos: [],
@computed get unfinishedTodoCount() {
return todoListStore.todos.filter(todo => !todo.finished).length;
}
};
ReactDOM.render(
<Provider todoListStore={todoListStore}>
<TodoListView />
</Provider>,
document.getElementById("root")
);
todoListStore.todos.push(
todoStore("Get Coffee"),
todoStore("Write simpler code")
);
todoListStore.todos[0].finished = true;
registerServiceWorker();