Move to Typescript.
This commit is contained in:
parent
34618860a4
commit
ac964ddd3f
16 changed files with 482 additions and 119 deletions
60
src/state/action.ts
Normal file
60
src/state/action.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import Maze from "../model/Maze";
|
||||
|
||||
export interface Action {
|
||||
type: string,
|
||||
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export const ID_ACTION_STARTED_LOADING = 'started_loading';
|
||||
|
||||
export function actionStartedLoading(): Action {
|
||||
return {
|
||||
type: ID_ACTION_STARTED_LOADING
|
||||
}
|
||||
}
|
||||
|
||||
export const ID_ACTION_LOADED_MAZE = 'loaded_maze';
|
||||
|
||||
export function actionLoadedMaze(maze: Maze): Action {
|
||||
return {
|
||||
type: ID_ACTION_LOADED_MAZE,
|
||||
maze
|
||||
}
|
||||
}
|
||||
|
||||
export const ID_ACTION_LOADING_FAILED = 'loading_failed';
|
||||
|
||||
export function actionLoadingFailed(reason: string): Action {
|
||||
return {
|
||||
type: ID_ACTION_LOADING_FAILED,
|
||||
reason
|
||||
};
|
||||
}
|
||||
|
||||
export const ID_ACTION_TOGGLED_SHOW_SOLUTION = 'toggled_show_solution';
|
||||
|
||||
export function actionToggledShowSolution(value: boolean): Action {
|
||||
return {
|
||||
type: ID_ACTION_TOGGLED_SHOW_SOLUTION,
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
export const ID_ACTION_CLOSED_MESSAGE_BANNER = 'closed_message_banner';
|
||||
|
||||
export function actionClosedMessageBanner(): Action {
|
||||
return {
|
||||
type: ID_ACTION_CLOSED_MESSAGE_BANNER
|
||||
}
|
||||
}
|
||||
|
||||
export const ID_ACTION_CLICKED_CELL = 'clicked_cell';
|
||||
|
||||
export function actionClickedCell(x: number, y: number): Action {
|
||||
return {
|
||||
type: ID_ACTION_CLICKED_CELL,
|
||||
x,
|
||||
y
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue