- Subscribe to specific path in your redux state
- Get notified only when the sub-state (corresponding to this path) is modified
- Get state difference
- Typescript and webpack
## Dependencies
- object-difference-ts
Configure store for using subscribeMiddleware
import {subscribeMiddleware} from '../lib/redux-subscribe-ts'
import {applyMiddleware, createStore} from 'redux'
import reducers from '../reducers'
export default function configureStore () {
const logger = createLogger();
return createStore(reducers, applyMiddleware(subscribeMiddleware))
}
### Subscribe to state modification for a specific path
import {subscribe} from '../lib/redux-subscribe-ts'
let onStateChange = function(stateChange) {
// stateChange.path: state path
// stateChange.prev: previous sub-state (corresponding to this path)
// stateChange.next: next sub-state
// stateChange.diff: differences between prev/next sub-states
}
// subscribe to 'store.tarifs'
store.dispatch(subscribe('path', 'uniquesubscriberkey', stateChange=>this.onStateChange(stateChange)))
// unsubscribe
store.dispatch(unsubscribe('path', 'uniquesubscriberkey'))
- package as NPM module
- tests
## Credits