member_webapp/@overflow/probe/store/trash/probe-host/probe-host.reducer.ts

50 lines
876 B
TypeScript
Raw Normal View History

2018-04-25 09:04:47 +00:00
import {
ReadByProbe,
ReadByProbeFailure,
ReadByProbeSuccess,
ActionType,
Actions,
} from './probe-host.action';
import {
State,
initialState,
} from './probe-host.state';
2018-05-02 08:09:39 +00:00
import { Probe } from '@overflow/commons-typescript/model/probe';
2018-04-25 09:04:47 +00:00
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;
}
}
}