0
votes

I have the following use-case. I use NgRx Store/Effects and I need to send a request to my back-end service. Request is initiated in my component, then dispatch to NgRx Effect and then sent to my back-end service. But I need to attach a piece of state to my Http request. So far I see two ways of doing it:

1) Select state from Store in the component and include into Action as payload 2) Inject Store into Effect and select piece of the state from Store in the specific effect

What is the suggested way from NgRx-driven point of view?

1

1 Answers

2
votes

Personally I would opt for option one if possible. Because it's easier to understand with the benefit that it's easy to test.

There are some times where this isn't possible or where it would cause too much overhead, if that's the case I use a withLatestFrom(storeSelector) inside an effect.