diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2018-04-30 00:34:13 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2018-04-30 00:38:46 +0200 |
commit | 5dd96bd91cbdc916b4bf758a6434d797393294ee (patch) | |
tree | b4f678bb6ae242f1e0f67f8efc00a241958a1375 /frontend/src/redux/games.js | |
parent | Fix sagas types (diff) | |
download | seven-wonders-5dd96bd91cbdc916b4bf758a6434d797393294ee.tar.gz seven-wonders-5dd96bd91cbdc916b4bf758a6434d797393294ee.tar.bz2 seven-wonders-5dd96bd91cbdc916b4bf758a6434d797393294ee.zip |
Complete redux action types
Diffstat (limited to 'frontend/src/redux/games.js')
-rw-r--r-- | frontend/src/redux/games.js | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/frontend/src/redux/games.js b/frontend/src/redux/games.js index 22b0d6bc..c6c13504 100644 --- a/frontend/src/redux/games.js +++ b/frontend/src/redux/games.js @@ -8,28 +8,36 @@ export const types = { UPDATE_GAMES: 'GAMES/UPDATE_GAMES', REQUEST_CREATE_GAME: 'GAMES/REQUEST_CREATE_GAME', REQUEST_JOIN_GAME: 'GAMES/REQUEST_JOIN_GAME', - REQUEST_START_GAME: 'GAMES/REQUEST_JOIN_GAME', + REQUEST_START_GAME: 'GAMES/REQUEST_START_GAME', ENTER_LOBBY: 'GAMES/ENTER_LOBBY', ENTER_GAME: 'GAMES/ENTER_GAME', }; -type Actions = - | { type: "GAMES/UPDATE_GAMES", games: GameMapType } - | { type: "GAMES/REQUEST_CREATE_GAME", gameId: string }; +export type UpdateGamesAction = { type: 'GAMES/UPDATE_GAMES', games: GameMapType }; +export type RequestCreateGameAction = { type: 'GAMES/REQUEST_CREATE_GAME', gameName: string }; +export type RequestJoinGameAction = { type: 'GAMES/REQUEST_JOIN_GAME', gameId: string }; +export type RequestStartGameAction = { type: 'GAMES/REQUEST_START_GAME' }; +export type EnterLobbyAction = { type: 'GAMES/ENTER_LOBBY', lobby: GameShape }; +export type EnterGameAction = { type: 'GAMES/ENTER_GAME' }; + +export type GamesAction = + | UpdateGamesAction + | RequestCreateGameAction + | RequestJoinGameAction + | RequestStartGameAction + | EnterLobbyAction + | EnterGameAction; export const actions = { - 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: GameShape) => ({ type: types.ENTER_LOBBY, lobby: fromJS(lobby) }), - enterGame: () => ({ type: types.ENTER_GAME }), + updateGames: (games: GameNormalMapType): UpdateGamesAction => ({ type: types.UPDATE_GAMES, games: fromJS(games) }), + requestJoinGame: (gameId: string): RequestJoinGameAction => ({ type: types.REQUEST_JOIN_GAME, gameId }), + requestCreateGame: (gameName: string): RequestCreateGameAction => ({ type: types.REQUEST_CREATE_GAME, gameName }), + requestStartGame: (): RequestStartGameAction => ({ type: types.REQUEST_START_GAME }), + enterLobby: (lobby: GameShape): EnterLobbyAction => ({ type: types.ENTER_LOBBY, lobby: fromJS(lobby) }), + enterGame: (): EnterGameAction => ({ type: types.ENTER_GAME }), }; -export const gamesReducer = (state: GamesState = new GamesState(), action: Actions) => { +export const gamesReducer = (state: GamesState = new GamesState(), action: GamesAction) => { switch (action.type) { case types.UPDATE_GAMES: return state.addGames(action.games); |