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; } } }