summaryrefslogtreecommitdiff
path: root/frontend/src/redux/games.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/redux/games.js')
-rw-r--r--frontend/src/redux/games.js15
1 files changed, 9 insertions, 6 deletions
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