member_webapp/@overflow/probe/store/trash/probe-host/probe-host.reducer.ts
2018-05-24 19:50:43 +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;
}
}
}