This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Actions, ActionTypes } from './actions'; | |
| import { featureAdapter, initialState, State } from './state'; | |
| export function featureReducer(state = initialState, action: Actions): State { | |
| switch (action.type) { | |
| case ActionTypes.LOAD_REQUEST: { | |
| return { | |
| ...state, | |
| isLoading: true, | |
| error: null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { User } from '../../models'; | |
| export interface State { | |
| user: User | null; | |
| isLoading: boolean; | |
| error: string; | |
| } | |
| export const initialState: State = { | |
| user: null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity'; | |
| import { MyModel } from '../../models'; | |
| export const featureAdapter: EntityAdapter< | |
| MyModel | |
| > = createEntityAdapter<MyModel>({ | |
| selectId: model => model.id, | |
| sortComparer: (a: MyModel, b: MyModel): number => | |
| b.someDate.toString().localeCompare(a.someDate.toString()) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Action } from '@ngrx/store'; | |
| import { MyModel } from '../../models'; | |
| export enum ActionTypes { | |
| LOAD_REQUEST = '[My Feature] Load Request', | |
| LOAD_FAILURE = '[My Feature] Load Failure', | |
| LOAD_SUCCESS = '[My Feature] Load Success' | |
| } | |
| export class LoadRequestAction implements Action { |
NewerOlder