Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wesleygrimes/433a525d339c3cc1d13a4baf12036205 to your computer and use it in GitHub Desktop.
Save wesleygrimes/433a525d339c3cc1d13a4baf12036205 to your computer and use it in GitHub Desktop.
Entity Feature Module - State
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