All files / src/lib/core/rest rest.reducers.ts

66.67% Statements 6/9
100% Branches 0/0
40% Functions 2/5
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                  1x         1x   1x           1x                   1x   1x  
import { createReducer, on } from '@ngrx/store';
import * as RestActions from './rest.actions';
import { Request } from './request';
​
export interface State {
  request: Request;
  response: any;
}
​
export const initialState: State = {
  request: undefined,
  response: undefined
};
​
export const reducer = createReducer(
  initialState,
  on(RestActions.request, (state, { request }) => ({
    ...state,
    request,
    response: undefined,
    error: undefined
  })),
  on(RestActions.requestSuccess, (state, { response }) => ({
    ...state,
    response
  })),
  on(RestActions.requestFailure, (state, { response }) => ({
    ...state,
    response
  }))
);
 
export const selectRequest = (state: State) => state.request;
 
export const selectResponse = (state: State) => state.response;