Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  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": {...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement