@alcadica/state-manager-logger
v1.0.3
Published
A logger for state-manager
Downloads
5
Readme
state-manager-logger
Install
npm i --save @alcadica/{state-manager,state-manager-logger}
Usage
This middleware will log every action dispatch inside your console
Example:
import createStore from '@alcadica/state-manager';
import Logger from '@alcadica/state-manager-logger';
const store = createStore({ foo: 100 });
const enabled = true;
store.use(Logger(enabled));
const increment = store.createAction<number>('increment');
store.reducer.connect((state, action, update) => {
if (action.type === increment.type) {
update({ foo: state.foo + action.payload });
}
});
store.dispatch(increment(1)) // this will log you action and state