member_webapp/@overflow/probe/store/probe-host/probe-host.reducer.ts
crusader d59d9379f9 ing
2018-05-24 15:44:13 +09:00

50 lines
876 B
TypeScript

import {
ReadByProbe,
ReadByProbeFailure,
ReadByProbeSuccess,
ActionType,
Actions,
} from './probe-host.action';
import {
State,
initialState,
} from './probe-host.state';
import { Probe } from '@overflow/commons-typescript/model/probe';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.ReadByProbe: {
return {
...state,
error: null,
isPending: true,
};
}
case ActionType.ReadByProbeSuccess: {
return {
...state,
error: null,
isPending: false,
probeHost: action.payload,
};
}
case ActionType.ReadByProbeFailure: {
return {
...state,
error: action.payload,
isPending: false,
probeHost: null,
};
}
default: {
return state;
}
}
}