Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Soccer Game App with Redux-Leaves

node v10.24.1
version: 1.0.0
endpointsharetweet
// setup const { createStore } = require('redux') const { reduxLeaves, bundle } = require('redux-leaves') // declare initial state const initialState = { crowdExcitement: 0, scoreboard: { home: 0, away: 0 } } // pass to reduxLeaves and get back a reducer and action creators const [reducer, actions] = reduxLeaves(initialState) const store = createStore(reducer) store.getState()
// at storeState.scoreboard.away, create an action to increment store.dispatch(actions.scoreboard.away.create.increment()) store.getState()
// in a single action, do both: // a) at storeState.scoreboard.home, increment state // b) at storeState.crowdExcitement, increment state by 5 const bundledAction = bundle([ actions.scoreboard.home.create.increment(), actions.crowdExcitement.create.increment(5) ]) store.dispatch(bundledAction) store.getState()
Loading…

no comments

    sign in to comment