Skip to content

Commit

Permalink
Update example to support sendOn option
Browse files Browse the repository at this point in the history
  • Loading branch information
zalmoxisus committed Apr 30, 2016
1 parent b1f7bcd commit 601afa8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions examples/toggle-monitoring/actions/monitoring.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const START_MONITORING = 'START_MONITORING';
export const STOP_MONITORING = 'STOP_MONITORING';
export const SEND_TO_MONITOR = 'SEND_TO_MONITOR';

export function startMonitoring() {
return {
Expand All @@ -12,3 +13,9 @@ export function stopMonitoring() {
type: STOP_MONITORING
};
}

export function sendToMonitor() {
return {
type: SEND_TO_MONITOR
};
}
5 changes: 4 additions & 1 deletion examples/toggle-monitoring/components/Counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component, PropTypes } from 'react';

class Counter extends Component {
render() {
const { startMonitoring, stopMonitoring, increment, decrement, counter } = this.props;
const { startMonitoring, stopMonitoring, sendToMonitor, increment, decrement, counter } = this.props;
return (
<p>
Clicked: {counter} times
Expand All @@ -14,6 +14,8 @@ class Counter extends Component {
<button onClick={startMonitoring}>Start monitoring</button>
{' '}
<button onClick={stopMonitoring}>Stop monitoring</button>
{' '}
<button onClick={sendToMonitor}>Send to the monitor</button>
</p>
);
}
Expand All @@ -22,6 +24,7 @@ class Counter extends Component {
Counter.propTypes = {
startMonitoring: PropTypes.func.isRequired,
stopMonitoring: PropTypes.func.isRequired,
sendToMonitor: PropTypes.func.isRequired,
increment: PropTypes.func.isRequired,
decrement: PropTypes.func.isRequired,
counter: PropTypes.number.isRequired
Expand Down
2 changes: 1 addition & 1 deletion examples/toggle-monitoring/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function mapStateToProps(state) {
}

function mapDispatchToProps(dispatch) {
return bindActionCreators({ ...CounterActions, ...MonitorActions}, dispatch);
return bindActionCreators({ ...CounterActions, ...MonitorActions }, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(Counter);
7 changes: 6 additions & 1 deletion examples/toggle-monitoring/store/configureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import thunk from 'redux-thunk';
import invariant from 'redux-immutable-state-invariant';
import devTools from 'remote-redux-devtools';
import reducer from '../reducers';
import { START_MONITORING, STOP_MONITORING, SEND_TO_MONITOR } from '../actions/monitoring';

export default function configureStore(initialState) {
const finalCreateStore = compose(
applyMiddleware(invariant(), thunk),
devTools({ realtime: false, startOn: 'START_MONITORING', stopOn: 'STOP_MONITORING' })
devTools({
realtime: false,
startOn: START_MONITORING, stopOn: STOP_MONITORING,
sendOn: SEND_TO_MONITOR
})
)(createStore);

const store = finalCreateStore(reducer, initialState);
Expand Down

0 comments on commit 601afa8

Please sign in to comment.