Created
November 30, 2021 15:08
-
-
Save aboudard/dbb11924a91d97ceeecd404d89742abd to your computer and use it in GitHub Desktop.
NgRx Custom selector for Todo entity
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 { 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