I'm creating a search in Angular 6. I'm having a hard time with my stream.
I want my rx stream to:
- Accepts text input changes
- Combine with a
subjectthat tells the stream to get more results (increment limit) when button clicked - Call the service
What I have works, except:
- When the subject emits, it does nothing, I expected the
switchmapto kick in and thus get server response.. How can I increment the limit each time the
subjectemits by 10?searchInput: FormControl = new FormControl(); showMore$: Subject<number> = new Subject(); ngOnInit() { this.searchInput .valueChanges .pipe( debounceTime(300), distinctUntilChanged(), withLatestFrom(this.showMore$.pipe(startWith(10), tap(val => { //how to increment the value here? }))), //switchmap not called when showMore$ emits... switchMap(([searchTerm, limit]) => { return this.myservice.search(searchTerm, limit) }), ) .subscribe(response => { this.results = response; }); } showMore(): void { this.showMore$.next(10); }