-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (41 loc) · 1.3 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
import {createStore, combineReducers} from 'redux-lite';
import * as router from 'router-redux-lite';
import todos from './reducers/todos';
import lastAction from './reducers/lastAction';
import * as TodosContainer from './components/TodosContainer';
import * as TodoForm from './components/TodoForm';
let main = document.querySelector('.main-js');
let store = createStore(combineReducers({
todos,
router: router.reducer,
lastAction
}));
store.dispatch({
type: 'FIRST'
});
main.appendChild(TodoForm.create({store}));
main.appendChild(TodosContainer.create({store}));
let routes = [{
route: '/',
handler(current) {
let routerView = document.querySelector('.route-view-js');
window.requestAnimationFrame(function() {
routerView.innerHTML = '';
routerView = null;
});
}
},
{
route: '/path',
handler(current) {
let routerView = document.querySelector('.route-view-js');
window.requestAnimationFrame(function() {
routerView.innerHTML = 'Path route';
routerView = null;
});
}
}];
router.config({store, routes, history: window.history});
document.querySelector('.go-to-js').addEventListener('click', function() {
store.dispatch(router.actions.navigate('/path'));
});