DEV Community

Discussion on: Angular - Zoned Out !

suvi profile image
Suvendu Karmakar Author • Edited on

Hey Sebastian, thanks a lot for your comment . I am really glad you liked it.

To answer your question, I have mentioned the problems with interceptor in the comments above. Let me just copy paste that here for your ease of understanding.

**** Copied from above ****

So I tried this with interceptors and opted the ZoneJs solution because of the following points :

  • The API calls which looks very simple here are actually 10+ services 100+ api calls and all kinds of forkjoins / flatMaps.
  • As I am checking with URL, if the URL is what I need, consider a scenario where 2 URLs which are almost identical in structure but I want to track one and don't want to track other . ZoneJS makes easy enough to run inside zone the one I want to track. While with interceptors it'll be a lot of if checks, which makes the code less maintainable.
  • Lastly I wanted to trigger the loader bar only after user hits the route, which is triggered inside a route resolver , which was very hard to do with an interceptor. With interceptors we are risking the loader component to be rendered on page where it's not needed ( or just put ngIf in the template checking for the route , which is very ugly solution TBH )

Hope it helps . :)