Commit 0bea8e1c authored by Thor-Herman's avatar Thor-Herman
Browse files

Create selectMoviesByAllIdsOrdering #10

Done in order to maintain order of items received in redux. If you order by Id then sorting won't be kept
parent 9d8bc388
import { createSelector } from "reselect";
import { RootState } from "../reducers";
import { Movie } from "../types/movies";
const selectMoviesById = (state: RootState): Record<number, Movie> => state.movies.byId;
const selectMoviesAllIds = (state: RootState): Array<number> => state.movies.allIds;
export const selectMoviesByAllIdsOrdering = createSelector(
selectMoviesById,
selectMoviesAllIds,
(byId, AllIds) => AllIds.map(id => byId[id])
);
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment