Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // from a navigation view
- function reducer(
- state: State,
- action: Action
- ): [State, reduxLoop.CmdType<Action>] {
- switch (action.type) {
- case "INIT OPERATOR VIEW": {
- const newState: State = {
- ...state,
- page: {
- name: "operator",
- state: operator.init,
- timerId: Maybe.nothing<TimerId>(),
- maxHeats: 5,
- heats: {
- status: "unloaded",
- }
- }
- };
- return [newState, reduxLoop.Cmd.none];
- }
- case "OPERATOR VIEW ACTION": {
- if (state.page.name !== "operator") {
- return [state, reduxLoop.Cmd.none];
- }
- const [newOperatorViewState, newOperatorViewCmd]
- : [operator.State, reduxLoop.CmdType<operator.Action>]
- = operator.reducer(state.page.state, action.action);
- const newState: State = {
- ...state,
- page: {
- ...state.page,
- name: "operator",
- state: newOperatorViewState
- }
- };
- const newCmd: reduxLoop.CmdType<ViewAction> = reduxLoop.Cmd.map(
- newOperatorViewCmd,
- (viewAction: operator.Action): ViewAction => {
- return { type: "OPERATOR VIEW ACTION", action: viewAction };
- });
- return [newState, newCmd];
- }
- case "LOGOUT": {...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement