我在摸摸 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)));