Redux Playground

node v4.9.1
version: master
endpointsharetweet
var { createStore, combineReducers } = require('redux') function photos (state = [], action) { switch (action.type) { case 'ADD_PHOTO': return [ ...state, action.photo ] default: return state } } function comments (state = [], action) { switch (action.type) { case 'ADD_COMMENT': return [ ...state, action.comment ] default: return state } } const store = createStore(combineReducers({ photos, comments: combineReducers({ tags: //, }) })) store.subscribe(() => console.log('New state incoming!', store.getState()) ) store.dispatch({ type: 'ADD_PHOTO', photo: { url: 'foo.jpg' } }) store.dispatch({ type: 'ADD_COMMENT', comment: { body: 'first' } }) undefined
Loading…

no comments

    sign in to comment