Skip to content

Instantly share code, notes, and snippets.

@aboudard
Created November 30, 2021 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aboudard/dbb11924a91d97ceeecd404d89742abd to your computer and use it in GitHub Desktop.
Save aboudard/dbb11924a91d97ceeecd404d89742abd to your computer and use it in GitHub Desktop.
NgRx Custom selector for Todo entity
import { EntitySelectorsFactory } from "@ngrx/data";
import { createSelector } from "@ngrx/store";
import { Todo } from "../dto/todo";
export const todoSelectors = new EntitySelectorsFactory().create<Todo>('Todo');
export const selectTodoByCategory = (category: string) => createSelector(
todoSelectors.selectEntities,
(data) => data.filter(c => c.category === category)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment