import { Action , createReducer , on } from '@ngrx/store' ; import { User } from '@nx-mean-starter/models' ; import { loadBatchEnd , loadBatchSuccess } from './actions' ; export interface PaginationState { ids : string [ ] ; done : boolean ; } export const initialState = { ids : [ ] , done : false , } ; export const factory = createReducer < PaginationState > ( initialState , on ( loadBatchSuccess , ( state , { users } ) => ( { ... state , ids : [ ... state . ids , ... users . map ( ( user ) => user . _id ) ] , } ) ) , on ( loadBatchEnd , state => ( { ... state , done : true , } ) ) ) ; export function paginationReducer ( state , action ) { return factory ( state , action ) ; }