You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
809 B
TypeScript

import { unreachable } from "../../../common/lib/dev.ts";
import { Reduce } from "../../state/lib/store.ts";
import { Action as HomeAction, reduce as reduceHome } from "../Home/actions.ts";
import {
Action as SchemaEditorAction,
reduce as reduceSchemaEditor,
} from "../SchemaEditor/actions.ts";
import { AppState } from "./view.ts";
export type Action = HomeAction | SchemaEditorAction;
export const reduce: Reduce<AppState, Action> = (state, action) => {
if (state.view.kind == "Home") {
return {
view: reduceHome(state.view.state, action as HomeAction),
};
}
if (state.view.kind == "SchemaEditor") {
return {
...state,
view: {
...state.view,
state: reduceSchemaEditor(
state.view.state,
action as SchemaEditorAction,
),
},
};
}
return unreachable();
};