2

我在摸摸 echoes -player 的代码,里面的效果用的很干净,有一个效果player-dearch.effects就是监听PlayerSearchActions.SEARCH_MORE_FOR_QUERY,这个效果依次调用服务searchMore中。youtube.search有趣的部分是动作searchMoreForQuery是从youtube-videos.component.

问题:有人说最好将调度功能移至“youtube.search”服务,然后从youtube-videos.component. 那真的是更好的设计吗?有什么建议可以改进吗?

@Effect()
  searchMoreForQuery$ = this.actions$
    .ofType(PlayerSearchActions.SEARCH_MORE_FOR_QUERY)
    .map(toPayload)
    .withLatestFrom(this.store)
    .map((latest: any[]) => latest[1])
    .filter((store: EchoesState) => !store.search.isSearching)
    .mergeMap((store: EchoesState) =>
      this.youtubeSearch.searchMore(store.search.pageToken.next)
      .search(store.search.query, store.search.queryParams)
      .map(youtubeResponse => this.playerSearchActions.searchResultsReturned(youtubeResponse)));
4

0 回答 0