Need an opinion to Angular-Resolver and Ionic

Hi all,

We all know the the resolver feature of Angular to fetch some data before you navigate to a different route.
I tested this feature in my Ionic application.

But so far I saw, when I navigate forward in Ionic the pages are stacked one on top of the other.
But when I navigate back it just removes the last page from the top of the pages stack and shows the page below again (page is already created…ngOnInit is not executed again)

But also the resolver is executed again and fetches the data again even no data has changed.
Can I suppress the resolver anyhow when I navigate to a page?

Am I on the wrong path?
Or is it in general not a good idea to use resolvers with Ionic?

Thanks for every feedback.

Regards,
Oliver

We have a fairly large project which does not use any Resolvers. While I suppose one can make an argument for why they could be used, using Observables and introspecting the parameters that are coming into a page are generally the more acceptable way of handling getting data into pages.

1 Like

Thank you for your feedback.
I also more on the side to not use resolvers.

But I’m just a little bit uncertain because I see a lot of Ionic articles promoting to use those resolvers
but they never address the problem with navigating back and that Ionic is using a special ion-router-outlet,

https://ionicframework.com/docs/angular/lifecycle#how-ionic-handles-the-life-of-a-page

At the end it would be interesting what the Ionic team is thinking about :slight_smile:

Resolvers were a lot more common before Observables became standard in Angular. They were pretty common in the Ionic v1 projects I did.
However, nowadays, when you are passed in arguments (either from the component, or from the router’s route params) the idea here is that you subscribe to those and when they update, then you update your view accordingly.
In the case of the above, since you are pushing something onto the stack, you’re not re-creating the component so the component shouldn’t be re-initializing.
Without seeing the code you are trying to use or understand the exact problem you are trying to solve, it is hard to say exactly how to respond to your question.

1 Like