1 |
|
2 |
|
3 | import { types } from './LoadingScreenActions';
|
4 | import type { LoadingScreenActionsType } from './LoadingScreenActions';
|
5 |
|
6 | export type LoadingScreenReducerStateType = {|
|
7 | percentage: ?number,
|
8 | |};
|
9 |
|
10 | export type LoadingScreenReducerType = (
|
11 | state: LoadingScreenReducerStateType,
|
12 | action: LoadingScreenActionsType
|
13 | ) => LoadingScreenReducerStateType;
|
14 |
|
15 | export default function LoadingScreenReducer(
|
16 | state: LoadingScreenReducerStateType = {
|
17 | percentage: 0,
|
18 | },
|
19 | action: LoadingScreenActionsType,
|
20 | ) {
|
21 | switch (action.type) {
|
22 | case types.SET_PERCENTAGE: {
|
23 | const { percentage } = action;
|
24 |
|
25 | return {
|
26 | ...state,
|
27 | percentage
|
28 | };
|
29 | }
|
30 | case types.ADD_PERCENTAGE: {
|
31 | const { addValue } = action;
|
32 |
|
33 | return {
|
34 | ...state,
|
35 | percentage: state.percentage + addValue
|
36 | };
|
37 | }
|
38 | default: return state;
|
39 | }
|
40 | }
|