title: Extracting specific data from ngrx/store
body: <p>So I have read <a href="https://stackoverflow.com/questions/38957510/get-single-item-from-ngrx-store">this</a> post several times, but the defined setup and examples now differ from the methods shown in the <a href="https://github.com/ngrx/example-app" rel="nofollow noreferrer">store example app</a>.</p>
  
  <p>I have written my store code, based heavily off of the example app, so if we continue to use the example app for reference in this post:</p>
  
  <p>Book Reducer:</p>
  
  <pre><code>export interface State {
    ids: string[];
    entities: { [id: string]: Book };
    selectedBookId: string | null;
  };
  
  const initialState: State = {
    ids: [],
    entities: {},
    selectedBookId: null,
  };
  
  export function reducer(state = initialState, action: book.Actions | collection.Actions): State {
    switch (action.type) {
      case book.ActionTypes.SEARCH_COMPLETE:
      case collection.ActionTypes.LOAD_SUCCESS: {
        const books = action.payload;
        const newBooks = books.filter(book =&gt; !state.entities[book.id]);
  
        const newBookIds = newBooks.map(book =&gt; book.id);
        const newBookEntities = newBooks.reduce((entities: { [id: string]: Book }, book: Book) =&gt; {
          return Object.assign(entities, {
            [book.id]: book
          });
        }, {});
  
        return {
          ids: [ ...state.ids, ...newBookIds ],
          entities: Object.assign({}, state.entities, newBookEntities),
          selectedBookId: state.selectedBookId
        };
      }
  
  export const getEntities = (state: State) =&gt; state.entities;
  export const getIds = (state: State) =&gt; state.ids;
  </code></pre>
  
  <p>Reducers index.ts (shortened but keeping relevant information):</p>
  
  <pre><code>import { createSelector } from 'reselect';
  import { compose } from '@ngrx/core/compose';
  import { storeFreeze } from 'ngrx-store-freeze';
  import { combineReducers } from '@ngrx/store';
  import * as fromBooks from './books';
  
  
  export interface State {
    books: fromBooks.State;
  }
  
  const reducers = {
    books: fromBooks.reducer,
  };
  
  const productionReducer: ActionReducer&lt;State&gt; = combineReducers(reducers);
  export function reducer(state: any, action: any) {
      return productionReducer(state, action);
  
  }
  
  export const getBooksState = (state: State) =&gt; state.books;
  export const getBookEntities = createSelector(getBooksState, fromBooks.getEntities);
  export const getBookIds = createSelector(getBooksState, fromBooks.getIds);
  </code></pre>
  
  <p>Now what I can't quite grasp is how the "query's" are built, what I want to be able to do is pass an ID say "456" to a function that will look inside State from the book with id "456". Return this data into an observable of Book so I can then use it inside my template/component whatever.</p>
  
  <p>I have looked at the example code for hours and just when I think I have grasped it, I can't work out what I have done wrong. If anyone is able to explain how to build a selector that takes custom arguments.</p>
  
  <p>I have used the exact code from the example app in the hope that if an answer is found it would be of help to future readers.</p>