Skip to content

Commit e82cbc1

Browse files
committed
refactor connected dispatches
1 parent d1e206f commit e82cbc1

File tree

28 files changed

+71
-127
lines changed

28 files changed

+71
-127
lines changed

lib/components/Alert/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ var Alert = (function (_super) {
3131
_super.apply(this, arguments);
3232
}
3333
Alert.prototype.render = function () {
34-
var _a = this.props, alert = _a.alert, close = _a.close;
34+
var _a = this.props, alert = _a.alert, alertClose = _a.alertClose;
3535
var action = alert.action, message = alert.message, open = alert.open, duration = alert.duration, color = alert.color;
36-
return (React.createElement(Snackbar_1.default, {style: styles, bodyStyle: { color: color }, open: open, message: message || '', action: action || '', autoHideDuration: duration || 2000, onActionTouchTap: close, onRequestClose: close}));
36+
return (React.createElement(Snackbar_1.default, {style: styles, bodyStyle: { color: color }, open: open, message: message || '', action: action || '', autoHideDuration: duration || 2000, onActionTouchTap: alertClose, onRequestClose: alertClose}));
3737
};
3838
Alert = __decorate([
3939
react_redux_1.connect(function (state) { return ({
4040
alert: state.alert,
41-
}); }, function (dispatch) { return ({
42-
close: function () { dispatch(actions_1.alertClose()); },
43-
}); }),
41+
}); }, { alertClose: actions_1.alertClose }),
4442
__metadata('design:paramtypes', [])
4543
], Alert);
4644
return Alert;

lib/components/AppMenu/CloseWindow.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ var CloseWindow = (function (_super) {
2727
return (React.createElement(IconButton_1.default, {onClick: this.props.windowToggle}, React.createElement(close_1.default, {color: 'white'})));
2828
};
2929
CloseWindow = __decorate([
30-
react_redux_1.connect(null, function (dispatch) { return ({
31-
windowToggle: function () { dispatch(actions_1.windowToggle()); },
32-
}); }),
30+
react_redux_1.connect(null, { windowToggle: actions_1.windowToggle }),
3331
__metadata('design:paramtypes', [])
3432
], CloseWindow);
3533
return CloseWindow;

lib/components/AppMenu/MenuLink/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ var MenuLink = (function (_super) {
2727
_super.apply(this, arguments);
2828
}
2929
MenuLink.prototype.render = function () {
30-
var _a = this.props, route = _a.route, title = _a.title, routeTo = _a.routeTo;
31-
return (React.createElement(MenuItem_1.default, {style: styles, primaryText: title ? title : route, onTouchTap: routeTo.bind(this, route), key: route}));
30+
var _a = this.props, route = _a.route, title = _a.title, routeSet = _a.routeSet;
31+
return (React.createElement(MenuItem_1.default, {style: styles, primaryText: title ? title : route, onTouchTap: routeSet.bind(this, route), key: route}));
3232
};
3333
MenuLink = __decorate([
34-
react_redux_1.connect(null, function (dispatch) { return ({
35-
routeTo: function (route) { dispatch(actions_1.routeSet(route)); },
36-
}); }),
34+
react_redux_1.connect(null, { routeSet: actions_1.routeSet }),
3735
__metadata('design:paramtypes', [])
3836
], MenuLink);
3937
return MenuLink;

lib/components/Common/RouteButton.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ var RouteButton = (function (_super) {
2323
_super.apply(this, arguments);
2424
}
2525
RouteButton.prototype.render = function () {
26-
var _a = this.props, label = _a.label, route = _a.route, style = _a.style, routeTo = _a.routeTo;
27-
return (React.createElement(RaisedButton_1.default, {label: label, style: style || {}, onTouchTap: routeTo.bind(this, route), secondary: true}));
26+
var _a = this.props, label = _a.label, route = _a.route, style = _a.style, routeSet = _a.routeSet;
27+
return (React.createElement(RaisedButton_1.default, {label: label, style: style || {}, onTouchTap: routeSet.bind(this, route), secondary: true}));
2828
};
2929
RouteButton = __decorate([
30-
react_redux_1.connect(null, function (dispatch) { return ({
31-
routeTo: function (route) { dispatch(actions_1.routeSet(route)); },
32-
}); }),
30+
react_redux_1.connect(null, { routeSet: actions_1.routeSet }),
3331
__metadata('design:paramtypes', [])
3432
], RouteButton);
3533
return RouteButton;

lib/components/Page/Hints/HintButton.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,19 @@ var HintButton = (function (_super) {
2424
_super.apply(this, arguments);
2525
}
2626
HintButton.prototype.render = function () {
27-
var _a = this.props, hintPosition = _a.hintPosition, hintsLength = _a.hintsLength, label = _a.label, type = _a.type, hintSet = _a.hintSet;
27+
var _a = this.props, hintPosition = _a.hintPosition, hintsLength = _a.hintsLength, label = _a.label, type = _a.type, hintPositionSet = _a.hintPositionSet;
2828
switch (type) {
2929
case 'next':
30-
return (React.createElement(FlatButton_1.default, {label: label, disabled: hintPosition > hintsLength - 2, onTouchTap: hintSet.bind(this, hintPosition + 1)}));
30+
return (React.createElement(FlatButton_1.default, {label: label, disabled: hintPosition > hintsLength - 2, onTouchTap: hintPositionSet.bind(this, hintPosition + 1)}));
3131
case 'prev':
32-
return (React.createElement(FlatButton_1.default, {label: label, disabled: hintPosition === 0, onTouchTap: hintSet.bind(this, hintPosition - 1)}));
32+
return (React.createElement(FlatButton_1.default, {label: label, disabled: hintPosition === 0, onTouchTap: hintPositionSet.bind(this, hintPosition - 1)}));
3333
}
3434
};
3535
HintButton = __decorate([
3636
react_redux_1.connect(function (state) { return ({
3737
hintPosition: state.hintPosition,
3838
hintsLength: selectors_1.hintsSelector(state).length,
39-
}); }, function (dispatch) { return ({
40-
hintSet: function (position) { dispatch(actions_1.hintPositionSet(position)); },
41-
}); }),
39+
}); }, { hintPositionSet: actions_1.hintPositionSet }),
4240
__metadata('design:paramtypes', [])
4341
], HintButton);
4442
return HintButton;

lib/components/Page/PageToolbar/Continue/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ var Continue = (function (_super) {
3030
_super.apply(this, arguments);
3131
}
3232
Continue.prototype.render = function () {
33-
return (React.createElement(RaisedButton_1.default, {style: styles, label: 'Continue', primary: true, onTouchTap: this.props.callNextPage}));
33+
return (React.createElement(RaisedButton_1.default, {style: styles, label: 'Continue', primary: true, onTouchTap: this.props.pageNext}));
3434
};
3535
Continue = __decorate([
36-
react_redux_1.connect(null, function (dispatch) { return ({
37-
callNextPage: function () { dispatch(actions_1.pageNext()); },
38-
}); }),
36+
react_redux_1.connect(null, { pageNext: actions_1.pageNext }),
3937
__metadata('design:paramtypes', [])
4038
], Continue);
4139
return Continue;

lib/components/Page/PageToolbar/Save/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ var Save = (function (_super) {
3030
_super.apply(this, arguments);
3131
}
3232
Save.prototype.render = function () {
33-
return (React.createElement(RaisedButton_1.default, {label: 'Save', style: styles, secondary: true, onTouchTap: this.props.save}));
33+
return (React.createElement(RaisedButton_1.default, {label: 'Save', style: styles, secondary: true, onTouchTap: this.props.editorSave}));
3434
};
3535
Save = __decorate([
36-
react_redux_1.connect(null, function (dispatch) { return ({
37-
save: function () { dispatch(actions_1.editorSave()); },
38-
}); }),
36+
react_redux_1.connect(null, { editorSave: actions_1.editorSave }),
3937
__metadata('design:paramtypes', [])
4038
], Save);
4139
return Save;

lib/components/Page/PageToolbar/ToggleDevTools/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ var ToggleDevTools = (function (_super) {
2828
_super.apply(this, arguments);
2929
}
3030
ToggleDevTools.prototype.render = function () {
31-
return (React.createElement(FlatButton_1.default, {style: styles, icon: React.createElement(code_1.default, null), onTouchTap: this.props.toggle}));
31+
return (React.createElement(FlatButton_1.default, {style: styles, icon: React.createElement(code_1.default, null), onTouchTap: this.props.editorDevToolsToggle}));
3232
};
3333
;
3434
ToggleDevTools = __decorate([
35-
react_redux_1.connect(null, function (dispatch) { return ({
36-
toggle: function () { dispatch(actions_1.editorDevToolsToggle()); },
37-
}); }),
35+
react_redux_1.connect(null, { editorDevToolsToggle: actions_1.editorDevToolsToggle }),
3836
__metadata('design:paramtypes', [])
3937
], ToggleDevTools);
4038
return ToggleDevTools;

lib/components/Progress/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ var Progress = (function (_super) {
4646
pagePosition: state.pagePosition,
4747
info: state.tutorial.info,
4848
tutorial: state.tutorial
49-
}); }, function (dispatch) { return ({
50-
progressLoad: function () { dispatch(actions_1.progressLoad()); }
51-
}); }),
49+
}); }, { progressLoad: actions_1.progressLoad }),
5250
__metadata('design:paramtypes', [])
5351
], Progress);
5452
return Progress;

lib/components/Start/Checks/VerifyButton.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ var VerifyButton = (function (_super) {
2323
_super.apply(this, arguments);
2424
}
2525
VerifyButton.prototype.render = function () {
26-
return (React.createElement(FlatButton_1.default, {label: 'Verify Setup Complete', primary: true, onTouchTap: this.props.verify}));
26+
return (React.createElement(FlatButton_1.default, {label: 'Verify Setup Complete', primary: true, onTouchTap: this.props.setupVerify}));
2727
};
2828
VerifyButton = __decorate([
29-
react_redux_1.connect(null, function (dispatch) { return ({
30-
verify: function () { dispatch(actions_1.setupVerify()); },
31-
}); }),
29+
react_redux_1.connect(null, { setupVerify: actions_1.setupVerify }),
3230
__metadata('design:paramtypes', [])
3331
], VerifyButton);
3432
return VerifyButton;

lib/components/Tutorials/LoadTutorials/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ var LoadTutorials = (function (_super) {
2727
return (React.createElement(FlatButton_1.default, {label: 'Check for Tutorials', secondary: true, onTouchTap: tutorialsFind}));
2828
};
2929
LoadTutorials = __decorate([
30-
react_redux_1.connect(null, function (dispatch) { return ({
31-
tutorialsFind: function () { dispatch(actions_1.tutorialsFind()); },
32-
}); }),
30+
react_redux_1.connect(null, { tutorialsFind: actions_1.tutorialsFind }),
3331
__metadata('design:paramtypes', [])
3432
], LoadTutorials);
3533
return LoadTutorials;

lib/components/Tutorials/SelectTutorial/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ var SelectTutorial = (function (_super) {
3030
}
3131
};
3232
SelectTutorial.prototype.render = function () {
33-
var _a = this.props, tutorial = _a.tutorial, selectTutorial = _a.selectTutorial;
33+
var _a = this.props, tutorial = _a.tutorial, tutorialSet = _a.tutorialSet;
3434
var name = tutorial.name;
35-
return (React.createElement(FlatButton_1.default, {label: this.displayName(name), primary: true, onTouchTap: selectTutorial.bind(this, name)}));
35+
return (React.createElement(FlatButton_1.default, {label: this.displayName(name), primary: true, onTouchTap: tutorialSet.bind(this, name)}));
3636
};
3737
SelectTutorial = __decorate([
38-
react_redux_1.connect(null, function (dispatch) { return ({
39-
selectTutorial: function (name) { dispatch(actions_1.tutorialSet(name)); },
40-
}); }),
38+
react_redux_1.connect(null, { tutorialSet: actions_1.tutorialSet }),
4139
__metadata('design:paramtypes', [])
4240
], SelectTutorial);
4341
return SelectTutorial;

lib/components/Tutorials/UpdateTutorial/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ var UpdateTutorial = (function (_super) {
3737
return (React.createElement("span", null, React.createElement(update_1.default, {style: styles.icon, color: colors_1.pink500, onTouchTap: tutorialUpdate.bind(this, tutorial.name)}), "``", React.createElement("span", {style: styles.latest}, tutorial.latest)));
3838
};
3939
UpdateTutorial = __decorate([
40-
react_redux_1.connect(null, function (dispatch) { return ({
41-
tutorialUpdate: function (title) { dispatch(actions_1.tutorialUpdate(title)); },
42-
}); }),
40+
react_redux_1.connect(null, { tutorialUpdate: actions_1.tutorialUpdate }),
4341
__metadata('design:paramtypes', [])
4442
], UpdateTutorial);
4543
return UpdateTutorial;

lib/components/Tutorials/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var Tutorials = (function (_super) {
3030
_super.call(this, props);
3131
}
3232
Tutorials.prototype.componentDidMount = function () {
33-
this.props.loadTutorials();
33+
this.props.tutorialsFind();
3434
};
3535
Tutorials.prototype.render = function () {
3636
var tutorials = this.props.tutorials;
@@ -43,9 +43,7 @@ var Tutorials = (function (_super) {
4343
Tutorials = __decorate([
4444
react_redux_1.connect(function (state) { return ({
4545
tutorials: state.tutorials,
46-
}); }, function (dispatch) { return ({
47-
loadTutorials: function () { dispatch(actions_1.tutorialsFind()); },
48-
}); }),
46+
}); }, { tutorialsFind: actions_1.tutorialsFind }),
4947
__metadata('design:paramtypes', [Object])
5048
], Tutorials);
5149
return Tutorials;

src/components/Alert/index.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ const styles = {
1515

1616
@connect(state => ({
1717
alert: state.alert,
18-
}), dispatch => ({
19-
close() { dispatch(alertClose()); },
20-
}))
18+
}), {alertClose})
2119
export default class Alert extends React.Component<{
22-
alert?: CR.Alert, close?: any
20+
alert?: CR.Alert, alertClose?: any
2321
}, {}> {
2422
render() {
25-
const {alert, close} = this.props;
23+
const {alert, alertClose} = this.props;
2624
const {action, message, open, duration, color} = alert;
2725
return (
2826
<Snackbar
@@ -32,8 +30,8 @@ export default class Alert extends React.Component<{
3230
message={message || ''}
3331
action={action || ''}
3432
autoHideDuration={duration || 2000}
35-
onActionTouchTap={close}
36-
onRequestClose={close}
33+
onActionTouchTap={alertClose}
34+
onRequestClose={alertClose}
3735
/>
3836
);
3937
}

src/components/AppMenu/CloseWindow.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import IconButton from 'material-ui/IconButton';
44
import NavigationClose from 'material-ui/svg-icons/navigation/close';
55
import {windowToggle} from '../../actions';
66

7-
@connect(null, dispatch => ({
8-
windowToggle() { dispatch(windowToggle()); },
9-
}))
7+
@connect(null, { windowToggle })
108
export default class CloseWindow extends React.Component<{
119
windowToggle?: any}, {}> {
1210
render() {

src/components/AppMenu/MenuLink/index.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ const styles = {
88
padding: '0px 2px',
99
};
1010

11-
@connect(null, dispatch => ({
12-
routeTo(route: string) { dispatch(routeSet(route)); },
13-
}))
11+
@connect(null, {routeSet})
1412
export default class MenuLink extends React.Component<{
15-
route: string, title?: string, routeTo?: any
13+
route: string, title?: string, routeSet?: any
1614
}, {}> {
1715
render() {
18-
const {route, title, routeTo} = this.props;
16+
const {route, title, routeSet} = this.props;
1917
return (
2018
<MenuItem
2119
style={styles}
2220
primaryText={title ? title : route}
23-
onTouchTap={routeTo.bind(this, route)}
21+
onTouchTap={routeSet.bind(this, route)}
2422
key={route}
2523
/>
2624
);

src/components/Common/RouteButton.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ import {connect} from 'react-redux';
33
import RaisedButton from 'material-ui/RaisedButton';
44
import {routeSet} from '../../actions';
55

6-
@connect(null, dispatch => ({
7-
routeTo(route: string) { dispatch(routeSet(route)); },
8-
}))
6+
@connect(null, {routeSet})
97
export default class RouteButton extends React.Component<{
10-
label: string, route: string, routeTo?: any, style?: Object
8+
label: string, route: string, routeSet?: any, style?: Object
119
}, {}> {
1210
render() {
13-
const {label, route, style, routeTo} = this.props;
11+
const {label, route, style, routeSet} = this.props;
1412
return (
1513
<RaisedButton
1614
label={label}
1715
style={style || {}}
18-
onTouchTap={routeTo.bind(this, route)}
16+
onTouchTap={routeSet.bind(this, route)}
1917
secondary={true}
2018
/>
2119
);

src/components/Page/Hints/HintButton.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,28 @@ import {hintsSelector} from 'core-coderoad/lib/selectors';
77
@connect(state => ({
88
hintPosition: state.hintPosition,
99
hintsLength: hintsSelector(state).length,
10-
}), dispatch => ({
11-
hintSet(position: number) { dispatch(hintPositionSet(position)); },
12-
}))
10+
}), {hintPositionSet})
1311
export default class HintButton extends React.Component<{
1412
hintPosition?: number, hintsLength?: number, type: 'next'|'prev', label: string
15-
hintSet?: any
13+
hintPositionSet?: any
1614
}, {}> {
1715
render() {
18-
const {hintPosition, hintsLength, label, type, hintSet} = this.props;
16+
const {hintPosition, hintsLength, label, type, hintPositionSet} = this.props;
1917
switch (type) {
2018
case 'next':
2119
return (
2220
<FlatButton
2321
label={label}
2422
disabled={hintPosition > hintsLength - 2}
25-
onTouchTap={hintSet.bind(this, hintPosition + 1)}
23+
onTouchTap={hintPositionSet.bind(this, hintPosition + 1)}
2624
/>
2725
);
2826
case 'prev':
2927
return (
3028
<FlatButton
3129
label={label}
3230
disabled={hintPosition === 0}
33-
onTouchTap={hintSet.bind(this, hintPosition - 1)}
31+
onTouchTap={hintPositionSet.bind(this, hintPosition - 1)}
3432
/>
3533
);
3634
}

src/components/Page/PageToolbar/Continue/index.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@ const styles = {
1111
top: '10px',
1212
};
1313

14-
@connect(null, dispatch => ({
15-
callNextPage() { dispatch(pageNext()); },
16-
}))
14+
@connect(null, {pageNext})
1715
export default class Continue extends React.Component<{
18-
callNextPage?: any
16+
pageNext?: any
1917
}, {}> {
2018
render() {
2119
return (
2220
<RaisedButton
2321
style={styles}
2422
label='Continue'
2523
primary={true}
26-
onTouchTap={this.props.callNextPage}
24+
onTouchTap={this.props.pageNext}
2725
/>
2826
);
2927
}

src/components/Page/PageToolbar/Save/index.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@ const styles = {
1111
top: '10px',
1212
};
1313

14-
@connect(null, dispatch => ({
15-
save() { dispatch(editorSave()); },
16-
}))
14+
@connect(null, {editorSave})
1715
export default class Save extends React.Component<{
18-
save?: any
16+
editorSave?: any
1917
}, {}> {
2018
render() {
2119
return (
2220
<RaisedButton
2321
label='Save'
2422
style={styles}
2523
secondary={true}
26-
onTouchTap={this.props.save}
24+
onTouchTap={this.props.editorSave}
2725
/>
2826
);
2927
}

0 commit comments

Comments
 (0)