labyrinth-frontend/src/state/action.ts

60 lines
1.2 KiB
TypeScript

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
}
}