Would you like to clone this notebook?

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

Cancel

Redux-Leaves playground

node v10.24.1
version: 3.0.0
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
const { reduxLeaves } = require('redux-leaves') const { createStore } = require('redux') const initialState = { counter: 0, list: [] }
// No more reduce or action creator boilerplate: it's all done by Redux-Leaves const [reducer, actions] = reduxLeaves(initialState)
// Create your Redux store with the Redux-Leaves reducer const store = createStore(reducer)
// confirm initial state store.getState()
// let's increment counter store.dispatch(actions.counter.create.increment()) store.getState()
// push something to list store.dispatch(actions.list.create.push('something')) store.getState()
// set a new path to a value store.dispatch(actions.create.path(['arbitrarily', 'long', 'path'], true)) store.getState()
// let's get funky store.dispatch(actions.list.create.do((leafState, treeState) => [...leafState, treeState.arbitrarily.long.path])) store.getState()
// ...too much? let's reset store.dispatch(actions.create.reset()) store.getState()
// use this as a sandbox! // docs: https://redux-leaves.js.org store.dispatch(actions.readyForFun.create.on()) store.getState()
Loading…

no comments

    sign in to comment