I have selector to get all posts, actually all entities, now I want to get single post/entity. Should I filter the posts I get from 'getAllPosts' selector or create another one and how to do it ?
Here are my selectors:
export const getPostsState = createFeatureSelector<fromPosts.PostState>('posts');
export const selectAllPosts = createSelector(getPostsState, fromPosts.getAllPosts);
export const selectPostsEntities = createSelector(getPostsState, fromPosts.getAllPosts);
export const selectPostsIds = createSelector(getPostsState, fromPosts.getPostsIds);
export const selectTotal = createSelector(getPostsState, fromPosts.getPostsTotal);
export const selectPostId = createSelector(getPostsState, fromPosts.getSelectedPostId);
export const getSelectedPost = createSelector(selectPostsEntities, selectPostId, (entities, id) => entities[id]);
As you see I have getSelectedPostId
and getSelectedPost
selectors but I'm not sure how to use it, I tried to follow some tutorials but nothing helps..