Created
May 30, 2018 18:14
-
-
Save wesleygrimes/433a525d339c3cc1d13a4baf12036205 to your computer and use it in GitHub Desktop.
Entity Feature Module - State
This file contains 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()) | |
}); | |
export interface State extends EntityState<MyModel> { | |
isLoading?: boolean; | |
error?: any; | |
} | |
export const initialState: State = featureAdapter.getInitialState( | |
{ | |
isLoading: false, | |
error: null | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment