SHARE
TWEET

Untitled

a guest Sep 16th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // from a navigation view
  2. function reducer(
  3.     state: State,
  4.     action: Action
  5. ): [State, reduxLoop.CmdType<Action>] {
  6.     switch (action.type) {
  7.         case "INIT OPERATOR VIEW": {
  8.             const newState: State = {
  9.                 ...state,
  10.                 page: {
  11.                     name: "operator",
  12.                     state: operator.init,
  13.                     timerId: Maybe.nothing<TimerId>(),
  14.                     maxHeats: 5,
  15.                     heats: {
  16.                         status: "unloaded",
  17.                     }
  18.                 }
  19.             };
  20.             return [newState, reduxLoop.Cmd.none];
  21.         }
  22.         case "OPERATOR VIEW ACTION": {
  23.             if (state.page.name !== "operator") {
  24.                 return [state, reduxLoop.Cmd.none];
  25.             }
  26.  
  27.             const [newOperatorViewState, newOperatorViewCmd]
  28.                 : [operator.State, reduxLoop.CmdType<operator.Action>]
  29.                 = operator.reducer(state.page.state, action.action);
  30.  
  31.             const newState: State = {
  32.                 ...state,
  33.                 page: {
  34.                     ...state.page,
  35.                     name: "operator",
  36.                     state: newOperatorViewState
  37.                 }
  38.             };
  39.  
  40.             const newCmd: reduxLoop.CmdType<ViewAction> = reduxLoop.Cmd.map(
  41.                 newOperatorViewCmd,
  42.                 (viewAction: operator.Action): ViewAction => {
  43.                     return { type: "OPERATOR VIEW ACTION", action: viewAction };
  44.                 });
  45.             return [newState, newCmd];
  46.         }
  47.  
  48.         case "LOGOUT": {...
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top