summaryrefslogtreecommitdiff
path: root/frontend/src/redux
diff options
context:
space:
mode:
authorVictor Chabbert <chabbertvi@eisti.eu>2017-05-28 23:39:12 +0200
committerVictor Chabbert <chabbertvi@eisti.eu>2017-05-28 23:39:12 +0200
commitbb2ced764938c4aa6b4e003b7dedb26c8a096b97 (patch)
tree7adf701e85f724b85fe042ef9ae00ff52e3c5213 /frontend/src/redux
parentUpgrade react-scripts (diff)
downloadseven-wonders-bb2ced764938c4aa6b4e003b7dedb26c8a096b97.tar.gz
seven-wonders-bb2ced764938c4aa6b4e003b7dedb26c8a096b97.tar.bz2
seven-wonders-bb2ced764938c4aa6b4e003b7dedb26c8a096b97.zip
Initial type checking work with flowtype
Diffstat (limited to 'frontend/src/redux')
-rw-r--r--frontend/src/redux/app.js1
-rw-r--r--frontend/src/redux/games.js15
2 files changed, 10 insertions, 6 deletions
diff --git a/frontend/src/redux/app.js b/frontend/src/redux/app.js
index 614e7d93..70074abd 100644
--- a/frontend/src/redux/app.js
+++ b/frontend/src/redux/app.js
@@ -1,3 +1,4 @@
+// @flow
export const makeSelectLocationState = () => {
return state => {
return state.get('routing');
diff --git a/frontend/src/redux/games.js b/frontend/src/redux/games.js
index d5953db1..f2df2492 100644
--- a/frontend/src/redux/games.js
+++ b/frontend/src/redux/games.js
@@ -1,5 +1,6 @@
+// @flow
import { fromJS } from 'immutable';
-import GamesState from '../models/games';
+import GamesState, { type GameMapType, type GameNormalMapType, type GameShape } from '../models/games';
export const types = {
UPDATE_GAMES: 'GAME/UPDATE_GAMES',
@@ -10,19 +11,21 @@ export const types = {
ENTER_GAME: 'GAME/ENTER_GAME',
};
+type Actions = { type: 'GAME/UPDATE_GAMES', games: GameMapType } | { type: 'GAME/REQUEST_CREATE_GAME', gameId: string };
+
export const actions = {
- updateGames: games => ({ type: types.UPDATE_GAMES, games: fromJS(games) }),
- requestJoinGame: gameId => ({ type: types.REQUEST_JOIN_GAME, gameId }),
- requestCreateGame: gameName => ({
+ updateGames: (games: GameNormalMapType) => ({ type: types.UPDATE_GAMES, games: fromJS(games) }),
+ requestJoinGame: (gameId: string) => ({ type: types.REQUEST_JOIN_GAME, gameId }),
+ requestCreateGame: (gameName: string) => ({
type: types.REQUEST_CREATE_GAME,
gameName,
}),
requestStartGame: () => ({ type: types.REQUEST_START_GAME }),
- enterLobby: lobby => ({ type: types.ENTER_LOBBY, lobby: fromJS(lobby) }),
+ enterLobby: (lobby: GameShape) => ({ type: types.ENTER_LOBBY, lobby: fromJS(lobby) }),
enterGame: () => ({ type: types.ENTER_GAME }),
};
-export default (state = new GamesState(), action) => {
+export default (state: GamesState = new GamesState(), action: Actions) => {
switch (action.type) {
case types.UPDATE_GAMES:
return state.addGames(action.games);
bgstack15