diff options
Diffstat (limited to 'frontend/src/redux')
-rw-r--r-- | frontend/src/redux/app.js | 1 | ||||
-rw-r--r-- | frontend/src/redux/games.js | 15 |
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); |