-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (38 loc) · 1020 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
40
41
42
43
44
45
46
47
const { createStore } = require('./redux/core/store/index');
const rootReducer = require('./redux/core/rootReducer');
const initialState = {
data: [
{
id: 1,
title: "My first book",
link: "dummy link",
},
],
};
// createStore(reducer, preloadedState, enhancer)
const store = createStore(rootReducer, initialState);
/**
* getState()
* subscribe()
* dispatch()
*/
// checking the initial value of the store
console.log("***** Initial State *****\n", store.getState());
// to watch sotre change over time
store.subscribe(() => {
console.log("Listener called");
});
// store.subscribe({
// test:true
// });
// to dispatch an action to update store
// dispatch takes an object with type and payload
store.dispatch({
type: "ADD_VIDEO",
payload: {
id: 2,
title: "My second book",
title: "My second dummy title",
},
});
console.log("***** next State *****\n", store.getState());