Skip to content
Snippets Groups Projects
Commit 2c2a8a3f authored by DD Liu's avatar DD Liu
Browse files

make monitors update method

parent a73efe86
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ const Storage = require('./storage'); ...@@ -8,6 +8,7 @@ const Storage = require('./storage');
const {connect} = require('react-redux'); const {connect} = require('react-redux');
const targets = require('../reducers/targets'); const targets = require('../reducers/targets');
const monitors = require('../reducers/monitors');
/* /*
* Higher Order Component to manage events emitted by the VM * Higher Order Component to manage events emitted by the VM
...@@ -30,6 +31,7 @@ const vmListenerHOC = function (WrappedComponent) { ...@@ -30,6 +31,7 @@ const vmListenerHOC = function (WrappedComponent) {
// we need to start listening before mounting the wrapped component. // we need to start listening before mounting the wrapped component.
this.props.vm.on('targetsUpdate', this.props.onTargetsUpdate); this.props.vm.on('targetsUpdate', this.props.onTargetsUpdate);
this.props.vm.on('SPRITE_INFO_REPORT', this.props.onSpriteInfoReport); this.props.vm.on('SPRITE_INFO_REPORT', this.props.onSpriteInfoReport);
this.props.vm.on('MONITORS_UPDATE', this.props.onMonitorsUpdate);
} }
componentDidMount () { componentDidMount () {
if (this.props.attachKeyboardEvents) { if (this.props.attachKeyboardEvents) {
...@@ -77,6 +79,7 @@ const vmListenerHOC = function (WrappedComponent) { ...@@ -77,6 +79,7 @@ const vmListenerHOC = function (WrappedComponent) {
onKeyDown, onKeyDown,
onKeyUp, onKeyUp,
onSpriteInfoReport, onSpriteInfoReport,
onMonitorsUpdate,
onTargetsUpdate, onTargetsUpdate,
/* eslint-enable no-unused-vars */ /* eslint-enable no-unused-vars */
...props ...props
...@@ -88,6 +91,7 @@ const vmListenerHOC = function (WrappedComponent) { ...@@ -88,6 +91,7 @@ const vmListenerHOC = function (WrappedComponent) {
attachKeyboardEvents: PropTypes.bool, attachKeyboardEvents: PropTypes.bool,
onKeyDown: PropTypes.func, onKeyDown: PropTypes.func,
onKeyUp: PropTypes.func, onKeyUp: PropTypes.func,
onMonitorsUpdate: PropTypes.func,
onSpriteInfoReport: PropTypes.func, onSpriteInfoReport: PropTypes.func,
onTargetsUpdate: PropTypes.func, onTargetsUpdate: PropTypes.func,
vm: PropTypes.instanceOf(VM).isRequired vm: PropTypes.instanceOf(VM).isRequired
...@@ -106,6 +110,9 @@ const vmListenerHOC = function (WrappedComponent) { ...@@ -106,6 +110,9 @@ const vmListenerHOC = function (WrappedComponent) {
}, },
onSpriteInfoReport: spriteInfo => { onSpriteInfoReport: spriteInfo => {
dispatch(targets.updateTarget(spriteInfo)); dispatch(targets.updateTarget(spriteInfo));
},
onMonitorsUpdate: monitorList => {
dispatch(monitors.updateMonitors(monitorList));
} }
}); });
return connect( return connect(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment