Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 1 | /* tslint:disable no-switch-case-fall-through */ |
| 2 | import {Action} from 'redux'; |
| 3 | import {UPDATE_FLAGS, UPDATE_NAME, UpdateFlagsAction, UpdateGlobalAction} from "./global.actions"; |
| 4 | |
| 5 | |
| 6 | |
| 7 | export interface GlobalState { |
| 8 | name : string; |
| 9 | flags : { [key: string]: boolean }; |
| 10 | } |
| 11 | |
| 12 | const initialState: GlobalState = { |
| 13 | name : null, |
| 14 | flags : null |
| 15 | }; |
| 16 | |
| 17 | |
| 18 | export const GlobalReducer = |
| 19 | function (state: GlobalState = initialState, action: Action): GlobalState { |
| 20 | switch (action.type) { |
| 21 | case UPDATE_NAME: |
| 22 | return Object.assign(state, state, (<UpdateGlobalAction>action)); |
| 23 | case UPDATE_FLAGS: |
| 24 | Object.assign(state, (<UpdateFlagsAction>action)); |
| 25 | return Object.assign({}, state); |
| 26 | default: |
| 27 | return state; |
| 28 | } |
| 29 | }; |