skip to Main Content

Javascript – RXJS dependent observables

I have 3 observables: query$ = this.q$.pipe(tap(() => this.page$.next(0)); filter$ = this.f$.pipe(tap(() => this.page$.next(0)); page$ = new BehaviorSubject<number>(0); combinetLatest({ query: this.query$, filter: this.filter$, page: this.page$ }) .pipe( switchMap(({ query, filter, page }) => { ... }) ); I have to…

VIEW QUESTION

Javascript – How can I create a lazy RxJS observable that calculates value only on once, and only when first subscribed?

I have the following class: class BucketManager { private readonly bucketNames$ = new BehaviorSubject<string[] | null>(null) bucketNames = this.bucketNames$.asObservable().pipe(filter(bucketNames => !!bucketNames)) as Observable<string[]> constructor() { this.init() } async init() { const fetchedBuckets = await someExpensiveLongCalculation() this.bucketNames$.next(fetchedBuckets) } } Currently, the…

VIEW QUESTION
Back To Top
Search