Angular 4 resolve not completed when using ngrx

有些话、适合烂在心里 提交于 2019-12-04 23:59:41

问题


I'm trying to use ngrx in a resolve in my app and for some reason it's not working.

This is how I got it previously, using a simple service in my resolve route:

resolve() {
  return this.service
    .getData()
    .map(data => data.pages.filter(page => page.parent === 'home'));
}

I then changed it into this:

resolve() {
  this.store.dispatch(new LoadConfigAction());
  return this.store
    .select('configuration')
    .do(data => console.log(data))
    .map((data: any) => data.pages.filter(page => page.parent === 'home'));
}

I get data in my console, so data is being retrieved, but the resolved is apparently not finishing, so my navigation does not happen.

I'm wondering if maybe the return type from this.store is not the same as an Observable from my service, but I'm a bit lost.

Any ideas?


回答1:


You need to complete the stream.

return this.store
    .select('configuration')
    .do(data => console.log(data))
    .map((data: any) => data.pages.filter(page => page.parent === 'home'))
    .first()


来源:https://stackoverflow.com/questions/45099626/angular-4-resolve-not-completed-when-using-ngrx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!