Cryze
Cryze

Reputation: 51

Should I call services directly when i use NGRX?

Does NGRX have any opinion about using services in components directly?

Example:

Login Component: Versions how to handle the login:

Are there any significant advantages or disadvantages here that I overlook? Or is it up to me how to do it?

Upvotes: 2

Views: 573

Answers (2)

Fateh Mohamed
Fateh Mohamed

Reputation: 21367

I suggest that you use Facades to handle interactions with the store for more simplicity and to eliminate the difficulties of maintaining and scaling, check this

enter image description here

Upvotes: 1

Tony
Tony

Reputation: 20132

You should not call a service in your component because your component will be depend on the service and when your application growth big you will have a problem to maintain your code

Using ngrx to dispatch an action in your component so that effect will handle a service call will be best practice because you are not depend on the service you just dispatch an action and effect will take care the rest for you

Upvotes: 0

Related Questions