diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-03 00:43:11 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2019-05-03 00:43:11 +0200 |
commit | d7f9f2470b972fbdc5b9b0aec2f939f1799968c8 (patch) | |
tree | ca3eaf2c90769d1a71c52d24a2fab9e568f18ee6 /frontend/src/redux/actions/user.ts | |
parent | Convert api package to typescript (diff) | |
download | seven-wonders-d7f9f2470b972fbdc5b9b0aec2f939f1799968c8.tar.gz seven-wonders-d7f9f2470b972fbdc5b9b0aec2f939f1799968c8.tar.bz2 seven-wonders-d7f9f2470b972fbdc5b9b0aec2f939f1799968c8.zip |
Convert redux actions to typescript
Diffstat (limited to 'frontend/src/redux/actions/user.ts')
-rw-r--r-- | frontend/src/redux/actions/user.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/frontend/src/redux/actions/user.ts b/frontend/src/redux/actions/user.ts new file mode 100644 index 00000000..29c85707 --- /dev/null +++ b/frontend/src/redux/actions/user.ts @@ -0,0 +1,17 @@ +import { Map } from 'immutable'; +import { ApiPlayer } from '../../api/model'; + +export const REQUEST_CHOOSE_USERNAME = 'USER/REQUEST_CHOOSE_USERNAME'; +export const SET_CURRENT_PLAYER = 'USER/SET_CURRENT_PLAYER'; +export const UPDATE_PLAYERS = 'USER/UPDATE_PLAYERS'; + +export type RequestChooseUsernameAction = { type: typeof REQUEST_CHOOSE_USERNAME, username: string }; +export type SetCurrentPlayerAction = { type: typeof SET_CURRENT_PLAYER, player: ApiPlayer }; +export type UpdatePlayersAction = { type: typeof UPDATE_PLAYERS, players: Map<string, ApiPlayer> }; + +export type PlayerAction = RequestChooseUsernameAction | SetCurrentPlayerAction | UpdatePlayersAction; + +export const actions = { + chooseUsername: (username: string): RequestChooseUsernameAction => ({ type: REQUEST_CHOOSE_USERNAME, username }), + setCurrentPlayer: (player: ApiPlayer): SetCurrentPlayerAction => ({ type: SET_CURRENT_PLAYER, player }), +}; |