Last active
March 17, 2017 02:39
-
-
Save srossross/e149f173328a289060b76ef6a60d6b61 to your computer and use it in GitHub Desktop.
maintain-state.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BB_UPDATE_STATE = '@@blackbox.updateState'; | |
const bbUpdateState = () => ({ | |
type: BB_UPDATE_STATE | |
}); | |
const serializeState = () => ({ | |
value: blackbox.getResult() | |
}); | |
const blackBoxReducer = (state = {}, action) => { | |
switch (action.type) { | |
case BB_UPDATE_STATE: | |
return serializeState(); | |
default: | |
break; | |
} | |
return state; | |
}; | |
const registerListener = () => { | |
blackbox.on('change', () => store.dispatch(bbUpdateState())); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment