Guest User

Untitled

a guest
Apr 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. export default (reducer, state = reducer(reducer._, {}), listeners = []) => ({
  2. dispatch(action){
  3. state = reducer(state, action)
  4. listeners.map(listener => listener(state))
  5. },
  6. subscribe: f => (
  7. listeners.push(f), i => listeners.splice(i = listeners.indexOf(f), !!~i)
  8. ),
  9. getState: () => state
  10. })
Add Comment
Please, Sign In to add comment