I'm starting a new angular app and doing the setup for the team. One thing I'm wondering: where do you put the logic to access the backend?
In my (first) case, about the accounts/auth, I need to store, username/email/accessToken, and typically every time a token is received, I want to start a timer to refresh the access token before it expires.
After some research, I see that some people recommend having the API call in the action handler in my State. But honestly, it feels a bit like mixing different responsibility, and since this will be for quite a big application, I'm a bit concerned that we end up with a state class that will be huge. Also in this case, when I receive my token, I need to have a timer to refresh it. I was more seing NGXS as a library to apply mutation on my state and propagate changes, not something should be responsible of having such logic(I'm maybe wrong?)
So, is there a recommended way of doing this with NGXS? Should we call a service that does the API call and then dispatch an action?