Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 resolve not completed when using ngrx

Tags:

angular

ngrx

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?

like image 226
David Avatar asked Jul 14 '17 09:07

David


1 Answers

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()
like image 165
undefined Avatar answered Oct 29 '22 04:10

undefined