In a @Component, should I always multicast the .select(myCustomSelector)?
e.g.
this.store.select(myCustomSelector).pipe(share());
Otherwise every time I do async, it will create a new subscription. Or is it fine because the selector is memoized?
I am wondering what's good practice.
No you should not use share() with your .select()
But it depends on what store implementation you are using.
in ngrx, ngxs, akita, the store is backed by an object and thus the observable returned from the select isn't going to trigger any side effects.
the store is then updated via a reducer, and then all the selects will get a new value, but since they are all working of this single object (state), it will not be a performance problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With