Reputation: 157
i need to use my store inside effect but im getting error. what is the correct way to do so?
Upvotes: 0
Views: 1524
Reputation: 2280
Since your selected state is itself an Observable you can combine this into your stream with the withLatestFrom
operator.
This is a rough example but I think you're looking for something along the lines of:
@Effect()
loadEstateOwners$ = this.actions$.pipe(
ofType(EstateOwnerListActionTypes.LoadEstateOwners),
withLatestFrom(this.store.select('userProfile')),
map(([actions, user]) => {
// Do something ...
})
);
More info on withLatestFrom
in the rxjs docs here:
https://www.learnrxjs.io/operators/combination/withlatestfrom.html
Upvotes: 1