diff options
author | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-28 23:39:12 +0200 |
---|---|---|
committer | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-28 23:39:12 +0200 |
commit | bb2ced764938c4aa6b4e003b7dedb26c8a096b97 (patch) | |
tree | 7adf701e85f724b85fe042ef9ae00ff52e3c5213 /frontend/src/redux/games.js | |
parent | Upgrade react-scripts (diff) | |
download | seven-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/games.js')
-rw-r--r-- | frontend/src/redux/games.js | 15 |
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); |