1/2
I manage state with NgRx and handle user interaction and data (to be provided) with RxJs. Let's say I have a movie library, based on the user selecting a genre or changing a page, the data shoud refetch (by dispatching an action to the store that then handles http request in an effect).
This is how I handle the params now inside a map operator:
moviesParams$ = combineLatest(
this.genreSelected$, // BehaviorSubject
this.pageSelected$, // BehaviorSubject
).pipe(
distinctUntilChanged(),
map(([genreId, page]) => {
if (genreId && page) {
// THE STORE ACTION BEING DISPATCH TO REFETCH
this.moviesFacade.fetchMoviesByGenreId(
page,genreId,
)
}
return ({ genreId, page})
}),
shareReplay({ refCount: true, bufferSize: 1}),
)