@michaelkariv wrote:
I am using ngrx (redux like) library as a core of my app.
I have effects (an ngrx term, something that listens to system-wide “actions” and react to some of them) that operate “api service”. the api service is simple - it just sends data back and force to server. Effects on the other hand dispatch “actions” of their own. For example, a ui component on a login form sends action “login” with payload of email and password. A corresponding effect gets it, calls the api service, gets response with a token, dispatches “login success” action.
So far so good, but sometimes a user misspelled an email - and api service returns an error. My question - should an effect deal with it - by prompting a Router or app’s root nav control to display a popup error message - or should it be left for a component to do?
An advantage of doing it in effect would be - using same error ui control universally, handling the error where it happened - and keeping components like login form true to its purpose - gathering user input.In the past Mike answered a somewhat similar question in the past.
But ngrx effects are not your regular service - it is more of like a business logic for the app, it seems to me - so does this logic still apply? I know it is as much of an ngrx question as it is ionic one. In fact ngrx sample app does just that - manages navigation in an effect - by calling injected Router methods.
What makes me want to ask this question here anyway is that ionic was in many ways prescriptive of the best practices and I want to be a good ionicdom citizen in this regard.
Posts: 1
Participants: 1