I like the idea of resolver
s.
You can say that:
- for a given route you expect some data to be loaded first
- you can just have a really simple component with no observable (as retrieving data from
this.route.snapshot.data
)
So resolvers make a lot of sense.
BUT:
- You're not changing the URL and displaying your requested component until you receive the actual response. So you can't (simply) show the user that something is happening by rendering your component and showing as much as you can (just like it's advised to, for the shell app with PWA). Which means that when having a bad connection, your user may have to just wait without visual indication of what's happening for a long time
- If you are using a resolver on a route with param, let's take as an example
users/1
, it'll work fine the first time. But if you go tousers/2
, well nothing will happen unless you start using another observable:this.route.data.subscribe()
So it feels like resolvers might be helpful retrieving some data BUT in practice I wouldn't use them in case there's a slow network and especially for routes with params.
Am I missing something here? Is there a way to use them with those real constraints?