Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active September 2, 2019 14:18
Show Gist options
  • Save alexytiger/2b2bee215b4708e9bcfae568662c3d37 to your computer and use it in GitHub Desktop.
Save alexytiger/2b2bee215b4708e9bcfae568662c3d37 to your computer and use it in GitHub Desktop.
export interface State extends EntityState<PurchaseWidgetModel> {
loaded: boolean;
selectedPurchaseContract: PurchaseContractModel;
}
export function sortByKey(a: PurchaseWidgetModel, b: PurchaseWidgetModel): number {
return a.productKey.localeCompare(b.productKey);
}
// based on https://next.ngrx.io/guide/entity/adapter
export const adapter: EntityAdapter<PurchaseWidgetModel> = createEntityAdapter<PurchaseWidgetModel>({
selectId: (product: PurchaseWidgetModel) => product.productKey,
sortComparer: sortByKey,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment