The following code is a ngrx 4 reducer could you make it compatible for ngrx 16 so it…
- User
The following code is a ngrx 4 reducer could you make it compatible for ngrx 16 so it works with createReducer()
export function reducer(state = initialState, action: any): State { switch (action.type) { case logicalService.ActionTypes.DELETE_LOGICAL_SERVICE_SUCCESS: return Object.assign({}, state, { isSaving: false, item: null, descriptors: null, lcnOverrides: null });
codecase descriptor.ActionTypes.ADD_DESCRIPTOR_SUCCESS: case descriptor.ActionTypes.UPDATE_DESCRIPTOR_SUCCESS: if (action.payload.targetType === 'LogicalService' && action.payload.targetId === state.item.id) { return Object.assign({}, state, { isSaving: false, descriptors: state.descriptors.set(action.payload.id, action.payload) }); } return state; case descriptor.ActionTypes.DELETE_DESCRIPTOR_SUCCESS: if (action.payload.targetType === 'LogicalService' && action.payload.targetId === state.item.id) { return Object.assign({}, state, { isSaving: false, descriptors: state.descriptors.delete(action.payload.id) }); } return state; case descriptor.ActionTypes.MOVE_DESCRIPTOR_UP_SUCCESS: case descriptor.ActionTypes.MOVE_DESCRIPTOR_DOWN_SUCCESS: if (action.payload.targetType === 'LogicalService' && action.payload.targetId === state.item.id) { let newDescriptors = state.descriptors.set(action.payload.id, action.payload); newDescriptors = newDescriptors.set(action['payload2'].id, action['payload2']); return Object.assign({}, state, { isSaving: false, descriptors: newDescriptors, }); } return state; case actions.ActionTypes.CREATE_SCHEDULE_SERVICE_SUCCESS: case actions.ActionTypes.UPDATE_SCHEDULE_SERVICE_SUCCESS: return Object.assign({}, state, { scheduleService: action.payload }); default: return state; - Assistant
- User
- Assistant
- User
The following code is a ngrx 4 reducer could you make it compatible for ngrx 16 so it works with createReducer()
export function reducer(state = initialState, action: actions.Actions | growlActions.Actions): State { switch (action.type) { case actions.ActionTypes.GET_PROVIDERS: case actions.ActionTypes.GET_SCHEDULE_HEALTH: return Object.assign({}, state, { isLoading: true }); case actions.ActionTypes.GET_SCHEDULE_HEALTH_SUCCESS: return Object.assign({}, state, { isLoading: false, scheduleHealths: action.payload }); case actions.ActionTypes.GET_SCHEDULE_HEALTH_FAIL: return Object.assign({}, state, { isLoading: false, messages: [{ severity: 'error', summary: 'Failed to retrieve services', detail: action.payload }] });
code - Assistant
Here's the modified code that is compatible with ngrx 6 and above, using the
createReducerfunction:typescript