angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

Add a way to easily reload the resolver #444

Open tbnovaes opened 5 years ago

tbnovaes commented 5 years ago

Happy path

I use the resolver to pre-fetch some data so when component is loaded I don't have things popping like xmas tree on the screen. All works fine, things are great, everybody is happy.

Sad path

I use the resolver to pre-fetch some data, api returns me any http error and no data. Things don't go as expected, I have no data to display, everybody is sad.

In this case I don't want to send the user to an error page, instead I want to load the same page, but customized with an error message and a reload button that will reload my resolver and maybe this time everything will work fine and people will be happy.

Workarounds

So I know that there are workarounds to the problem, but all come with some caveat, for example:

There are few others, but all add a lot of extra steps. Which may be fine when we are talking about just one route of the entire app, but not fine when you have to do it in multiple routes. Which also generates a lot of boilerplate.

Expected

It would be great to have some way of forcing the route to reload its resolver. Something like activatedRoute.resolve()