From f5c5728ede867b53b0323b53132208dd0fe048cd Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sun, 20 Oct 2019 09:52:39 -0400 Subject: [PATCH] update README --- README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cb97236..b26a577 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,27 @@ const { middleware, createStore, } = updux({ - initial: {}, + initial: { + counter: 0, + }, subduxes: { otherUpdux, }, mutations: { + inc: ( increment = 1 ) => u({counter: s => s + increment }) }, effects: { + '*' => api => next => action => { + console.log( "hey, look, an action zoomed by!", action ); + next(action); + }; }, -}) +}); + +const store = createStore(); + +store.dispatch.inc(3); ``` # Description @@ -244,10 +255,6 @@ store.dispatch.addTodo(...); store.dispatch( actions.addTodo(...) ); ``` - - - - # Example #### battle.js @@ -260,7 +267,7 @@ import log from './log'; import bogeys from './bogeys'; const { createStore } = updux({ - reducers: { game, log, bogeys } + subduxes: { game, log, bogeys } }) export default createStore; @@ -276,7 +283,6 @@ import u from 'updeep'; import { calculateMovement } from 'game/rules'; - export default updux({ initial: { game: "", players: [], turn: 0, }, mutations: { @@ -305,13 +311,12 @@ export default updux({ #### log.js - ``` import { updux } from 'updux'; export default updux({ initial: [], - actions: { + mutations: { '*': (payload,action) => state => [ ...state, action ], }, }); @@ -353,6 +358,5 @@ battle.dispatch.play_game(); [Redux]: https://redux.js.org -[rematch]: https://rematch.github.io [Updeep]: https://github.com/substantial/updeep [VueX]: https://vuex.vuejs.org/