Ali Aljonde
Ali Aljonde

Reputation: 137

using NgRx Effect

We are developing an app using Angular 8 and NgRx for state management. In the app we have about 10 components, every one of them uses a unique API all the API need same data from the user (id) -- { the user enter the (id) in input field }

The question: Should I use the effects to call all the API when the user enter the (id) and store the data in the STORE or just store the id in state then every component call its own API when id change?

Note: The data coming from the API is used in its own component only.

Upvotes: 1

Views: 226

Answers (1)

satanTime
satanTime

Reputation: 13574

To use an effect to call an API - that's the right way. Simply dispatch its action.

To store response data in store - depends. If you want to use it later somewhere in your app - then store it, if you don't need it - then add { dispatch: false } to the createEffect options to avoid post process of it.

Upvotes: 1

Related Questions