const {createStore} = Redux const initState = { todos: [], posts: [] } function myreducer(state = initState, action){ console.log(action, state) if(action.type == 'ADD_TODO') { return { ...state, todos: [...state.todos , action.todo ] } } if(action.type == 'ADD_POST') { return { ...state, posts: [...state.posts , action.posts ] } } } const store = createStore(myreducer) store.subscribe(() => { console.log("state updates") console.log(store.getState()) }) const todoAction = { type: 'ADD_TODO', todo: 'buy milk' } //dispatch action store.dispatch(todoAction) store.dispatch({type: 'ADD_TODO', todo: 'heera'}) store.dispatch({type: 'ADD_TODO', todo: 'keera'}) store.dispatch({type: 'ADD_POST', posts: 'POSTA ENTRY'})