Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 4ec6434

Browse files
committed
🎉 Bump up to redux-observable to 1.0.0!!
1 parent 71480be commit 4ec6434

File tree

15 files changed

+1894
-9777
lines changed

15 files changed

+1894
-9777
lines changed

dist/bundle.js

Lines changed: 25 additions & 7949 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1758 additions & 1712 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@
1212
"author": "[email protected]",
1313
"license": "MIT",
1414
"dependencies": {
15-
"@types/googlemaps": "^3.30.7",
16-
"@types/react": "^16.0.38",
17-
"@types/react-dom": "^16.0.4",
18-
"@types/react-redux": "^5.0.15",
19-
"@types/redux": "^3.6.0",
15+
"@types/googlemaps": "^3.30.16",
16+
"@types/react": "^16.7.9",
17+
"@types/react-dom": "^16.0.11",
18+
"@types/react-redux": "^6.0.10",
19+
"@types/redux": "^3.6.31",
2020
"@types/scriptjs": "0.0.2",
21-
"react": "^16.2.0",
22-
"react-dom": "^16.2.0",
23-
"react-redux": "^5.0.7",
24-
"redux": "^3.7.2",
25-
"redux-observable": "^0.18.0",
26-
"rxjs": "^5.5.6",
27-
"scriptjs": "^2.5.8",
28-
"typesafe-actions": "^1.1.2"
21+
"react": "^16.2.3",
22+
"react-dom": "^16.2.3",
23+
"react-redux": "^5.1.1",
24+
"redux": "^4.0.1",
25+
"redux-observable": "^1.0.0",
26+
"rxjs": "^6.3.3",
27+
"scriptjs": "^2.5.9",
28+
"typesafe-actions": "^2.0.4"
2929
},
3030
"devDependencies": {
31-
"awesome-typescript-loader": "^3.4.1",
32-
"redux-devtools": "^3.4.1",
33-
"source-map-loader": "^0.2.3",
34-
"typescript": "^2.7.2",
35-
"webpack": "^3.11.0"
31+
"awesome-typescript-loader": "^5.2.1",
32+
"source-map-loader": "^0.2.4",
33+
"typescript": "^3.2.1",
34+
"webpack": "^4.26.1",
35+
"webpack-cli": "^3.1.2"
3636
}
3737
}

src/actions/index.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,15 @@ import {
44
WEATHER_GET,
55
WEATHER_SET,
66
MAP_READY,
7+
WEATHER_ERROR,
78
} from "../constants";
89

9-
export interface Action {
10-
type: string;
11-
payload?: {};
12-
params?: {};
13-
}
10+
import Weather from "../shared/models/Weather";
1411

15-
export interface WeatherAction extends Action {
16-
params: {
17-
lat: number;
18-
lng: number;
19-
};
20-
}
12+
export const weatherGetAction = createAction(WEATHER_GET, resolve => (lat: number, lng: number) => resolve({ lat, lng }));
2113

22-
export const weatherGetAction = createAction(WEATHER_GET, (params = {}) => ({
23-
type: WEATHER_GET,
24-
params,
25-
}));
14+
export const weatherSetAction = createAction(WEATHER_SET, resolve => (weather: Response) => resolve(weather));
2615

27-
export const weatherSetAction = createAction(WEATHER_SET, (payload = {}) => ({
28-
type: WEATHER_SET,
29-
payload,
30-
}));
16+
export const weatherErrorAction = createAction(WEATHER_ERROR, resolve => (error: Error) => resolve(error));
3117

32-
export const mapReadyAction = createAction(MAP_READY, () => ({
33-
type: MAP_READY
34-
}));
18+
export const mapReadyAction = createAction(MAP_READY);

src/components/App.connect.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import { connect } from "react-redux";
1+
import { ActionType } from 'typesafe-actions';
2+
import { Dispatch } from 'redux';
3+
import { connect } from 'react-redux';
4+
5+
import * as actions from "../actions";
26

37
import { RootState } from "../reducers";
48

5-
import App, { AppProps } from "./App";
9+
import App from "./App";
10+
11+
type Action = ActionType<typeof actions>;
612

713
interface OwnProps {
814
}
@@ -11,10 +17,7 @@ const mapStateToProps = (state: RootState) => ({
1117
loading: !state.map.ready,
1218
});
1319

14-
const mapDispatchToProps = (dispatch: Function, props: OwnProps) => ({
20+
const mapDispatchToProps = (dispatch: Dispatch<Action>, props: OwnProps) => ({
1521
});
1622

17-
export default connect<{}, {}, AppProps>(
18-
mapStateToProps,
19-
mapDispatchToProps,
20-
)(App) as React.ComponentClass<OwnProps>
23+
export default connect(mapStateToProps, mapDispatchToProps)(App);

src/components/Map.connect.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import { connect } from "react-redux";
1+
import { ActionType } from 'typesafe-actions';
2+
import { Dispatch, bindActionCreators } from 'redux';
3+
import { connect } from 'react-redux';
24

3-
import { weatherGetAction, mapReadyAction } from "../actions"
4-
import { RootState } from "../reducers"
5+
import * as actions from "../actions";
56

6-
import Map, { MapProps } from "./Map";
7+
import { RootState } from "../reducers";
8+
9+
type Action = ActionType<typeof actions>;
10+
11+
import Map from "./Map";
712

813
interface OwnProps {
914
}
1015

1116
const mapStateToProps = (state: RootState) => ({});
1217

13-
const mapDispatchToProps = (dispatch: Function, props: OwnProps) => ({
14-
getWeather: (payload: {}) => dispatch(weatherGetAction(payload)),
15-
mapReady: () => dispatch(mapReadyAction()),
16-
});
18+
const mapDispatchToProps = (dispatch: Dispatch<Action>, props: OwnProps) => bindActionCreators({
19+
getWeather: (lat: number, lng: number) => actions.weatherGetAction(lat, lng),
20+
mapReady: () => actions.mapReadyAction(),
21+
}, dispatch);
1722

18-
export default connect<{}, {}, MapProps>(
19-
mapStateToProps,
20-
mapDispatchToProps,
21-
)(Map) as React.ComponentClass<OwnProps>
23+
export default connect(mapStateToProps, mapDispatchToProps)(Map);

src/components/Map.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import * as scriptjs from "scriptjs";
33

44
export interface MapProps {
5-
getWeather: Function;
5+
getWeather: (lat: number, lng: number) => undefined;
66
mapReady: Function;
77
}
88

@@ -45,10 +45,10 @@ export default class Map extends React.Component<MapProps, MapState> {
4545
});
4646

4747
this.map.addListener("click", (event) => {
48-
this.props.getWeather({
49-
lat: event.latLng.lat(),
50-
lng: event.latLng.lng(),
51-
});
48+
this.props.getWeather(
49+
event.latLng.lat(),
50+
event.latLng.lng(),
51+
);
5252
});
5353

5454
this.props.mapReady();

src/components/Weather.connect.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import { connect } from "react-redux";
1+
import { ActionType } from 'typesafe-actions';
2+
import { Dispatch } from 'redux';
3+
import { connect } from 'react-redux';
24

3-
import { RootState } from "../reducers"
5+
import * as actions from "../actions";
6+
7+
import { RootState } from "../reducers";
8+
9+
type Action = ActionType<typeof actions>;
410

511
import { Weather, WeatherProps } from "./Weather";
612

@@ -11,9 +17,6 @@ const mapStateToProps = (state: RootState) => ({
1117
weather: state.weather.weather,
1218
});
1319

14-
const mapDispatchToProps = (dispatch: Function, props: OwnProps) => ({});
20+
const mapDispatchToProps = (dispatch: Dispatch<Action>, props: OwnProps) => ({});
1521

16-
export default connect<{}, {}, WeatherProps>(
17-
mapStateToProps,
18-
mapDispatchToProps,
19-
)(Weather) as React.ComponentClass<OwnProps>
22+
export default connect(mapStateToProps, mapDispatchToProps)(Weather);

src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const MAP_READY = "@@map/READY";
22
export const WEATHER_GET = "@@weather/GET";
33
export const WEATHER_SET = "@@weather/SET";
4+
export const WEATHER_ERROR = "@@weather/ERROR";

0 commit comments

Comments
 (0)