Is there a way (or is it even appropriate) to pass a parameter to @ngrx/component-store selector? I was excited about component-store because effects and updaters can take an Observable as a parameter. This means that that Observable does not have to be subscribed to in a component. But there is not appeared to be a way to use an Observable as a parameter to a selector.
selectMovie(movieId: string) {
return this.select((state) => state.movies.find(m => m.id === movieId));
}
I still wonder how to pass movieId as an Observable and return values from selector when movieId or state was modified.
Judging by one of the signatures:
select<R, S1>(
s1: Observable<S1>,
projector: (s1: S1) => R,
config?: SelectConfig
): Observable<R>;
I think you can achieve what you're looking for by doing:
select(observable1$, () => {})
You can have use more than one observable, as long as the last arguments are (in this order) either the projectioFn
and configObject
or only the projectionFn
.
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