title: Angular 4 cannot select State from Store
body: <p>I have a <code>NGRX</code> store and I want to pass a mapping function to the <code>select()</code> to select some data from it.</p>
  
  <p>The interface I want to fetch from is this one:</p>
  
  <pre><code>export interface Thread {
      id: number;
      messageIds: number[];
      participants: {[key: number]: number};
  }
  </code></pre>
  
  <p>I manage to get some other data from the Store via the mapping functions <code>mapStateToUserName</code> and <code>unreadMessagesCounter</code> but for some reason <code>stateToThreadSummariesSelector</code> is not working.</p>
  
  <p>When I try to log the <code>state</code> inside the <code>stateToThreadSummariesSelector</code> it is <code>undefined</code>.</p>
  
  <p>ApplicationState interface: </p>
  
  <pre><code>export interface ApplicationState {
      uiState: UiState;
      storeData: StoreData;
  }
  </code></pre>
  
  <p>code: </p>
  
  <pre><code>  userName: Observable&lt;string&gt;;
    unreadMessagesCounter: Observable&lt;number&gt;;
    threadSummaries: Observable&lt;ThreadSummary[]&gt;;
  
    constructor(private threadsService: ThreadsService, private store: Store&lt;ApplicationState&gt;) {
      this.userName = store.skip(1).map(this.mapStateToUserName)
      this.unreadMessagesCounter = store.skip(1).map(this.mapStateToUnreadMessagesCounter)
  
      this.threadSummaries = store.select(this.stateToThreadSummariesSelector)
    }
  
    stateToThreadSummariesSelector(state: ApplicationState) {
        console.log(state) // undefined
  
        const threads = _.values&lt;Thread&gt;(state.storeData.threads)
  
        return threads.map(_.partial(this.mapThreadToThreadSummaries, state));
    }
  
    mapThreadToThreadSummaries(state: ApplicationState, thread: Thread): ThreadSummary {
      const names = _.keys(thread.participants).map(participantId =&gt; state.storeData.participants[participantId].name)
      const lastMessageId = _.last(thread.messageIds)
      const lastMessage = state.storeData.messages[lastMessageId]
  
      return {
          id: thread.id,
          participantNames: _.join(names, ","),
          lastMessageText: lastMessage.text,
          timestamp: lastMessage.timestamp
      }
    }
  
    mapStateToUserName(state: ApplicationState): string {
      return state.storeData.participants[state.uiState.userId].name
    }
  
    mapStateToUnreadMessagesCounter(state: ApplicationState): number {
      const currentUserId = state.uiState.userId;
  
      return _.values&lt;Thread&gt;(state.storeData.threads).reduce((acc, thread) =&gt; acc + thread.participants[currentUserId], 0)
    }
  </code></pre>