Questions tagged [switchmap]

Questions about switchMap operator, an RxJS flattening operator to handle observables and emit values.

switchMap is an RxJS flattening operator to handle observables and emit values. Used in coding reactive web pages.

This operation works well to handle observables, where there is no need to ensure that the call has succeeded, only returning the value from the latest call.

Related tags:

195 questions
0
votes
0 answers

Filter multiple dropdown values in Angular 8 based on some observables

I have the following form controls (parent1, parent2, parent3) which are check boxes. When user checks/unchecks any of these, the following form arrays consisting of multiple select checkboxes with the sample data given below: // Child1 with…
0
votes
1 answer

How to execute multiple calls and subscribes using different strategies?

Let´s say I have something like the code below this.sharedService.getvalorMensalObservable().pipe( switchMap(x => { this.valorMensal = x; return this.simuladorGvService.obterTaxasRecebaRapido(this.valorMensal); //instead of returning,…
0
votes
1 answer

Chaining Multiple Transformations.switchMap off of one LiveData source

I'm learning Android for a school project, we have to use Java and we can't use any external libraries. I am creating a college student course load tracking app. Currently, I am working on the activity that will detail the information for a Course…
0
votes
2 answers

Rxjs/Typescript: ExpressionChangedAfterItHasBeenCheckedError

I'm using ng-select custom server-side search to load data, whether the user provided a search term or not. component.html
shAkur
  • 944
  • 2
  • 21
  • 45
0
votes
1 answer

switchMap with empty value

I'm using ng-select custom server-side search to load data based on what the user types. Currently it only works if a keyword is actually pressed. I'd like to trigger the http request each time the dropdown is opened, even if the search term is…
shAkur
  • 944
  • 2
  • 21
  • 45
0
votes
1 answer

dispatch ngxs action in switchMap ignoring the return value

There must be a standard way to solve this, but I haven't found anything yet. I am probably not phrasing my search correctly. I have a search input field and as is good practice, I use the switchmap operator to cancel previous http requests, when…
user3629892
  • 2,960
  • 9
  • 33
  • 64
0
votes
1 answer

Angular input search not working using switchmap while also trying to display some init data

I have my search implemented in Angular using async pipe with an observable. I assign the observable to the search observable done with switchmap. But it does not work! I think it has something to do with one assigning is overwriting the other one.…
Merv
  • 1,039
  • 2
  • 12
  • 22
0
votes
1 answer

Return object inside switchMap

I am new to rjxs programming so wondering how can I do the following. const downloadUrls$: any = filelist.map((file: any) => { const fileName = ... const path = ... const fileRef = .... const task: any = ... // get…
Saurabh Kumar
  • 16,353
  • 49
  • 133
  • 212
0
votes
1 answer

Potential race condition using ngrx nested switchMaps

I have an Angular 9 application that for the most part uses observables. In one component I need to: Get all companies (as they contain certain info I need) Then get all responses and map some of the extra info in the companies (i.e. the company…
Ben Thomson
  • 1,083
  • 13
  • 29
0
votes
1 answer

Using rxjs 6 how can I create a cancellable web request pipeline with a cache, and which limits the number of requests happening at the same time

I hope someone is able to point me in the right direction, because I am struggling with combining concurrency and the ability to cancel queued requests in rxjs. I am going to try and explain this in sequential events. Say we have observable A, which…
eXigiouS
  • 21
  • 4
0
votes
1 answer

Angular Service not executing switchmap

I have a switchmap that won't go inside. I had it working earlier today, but for some reason now it's not outputting alert("INSIDE SWITCHMAP") or the console.logs inside the switchmap. Also this little block of alerts alert(userId); …
user6680
  • 79
  • 6
  • 34
  • 78
0
votes
1 answer

Strange behaviour of an array of objects when passed into switchMap() in RXJS

I have a simple goal of creating an observable that emits a list of all the countries in the world. The type of the observable is Country[], i.e. the store value is typed as an array of objects. However, when passed to switchMap, it magically gets…
petajamaja
  • 520
  • 2
  • 9
  • 26
0
votes
0 answers

Angular 6 jasmine testcases for ngrx/effects

I am trying to write test cases for the effects. Can anyone please help me on how to test the switchMap function inside it. Thanks in advance. Here is my function loadMovies$ = createEffect(() => this.actions$.pipe( ofType('[Login Page]…
sravanthi
  • 175
  • 1
  • 1
  • 15
0
votes
0 answers

Unit test interval and switchMap

I have a component with the following ngOnInit function which polls a service method for status updates: ngOnInit() { this.waitingForMachineToStart = interval(2000) .pipe( distinctUntilChanged(), switchMap(() =>…
testeurFou
  • 71
  • 3
  • 11
0
votes
1 answer

Invoke modal inside SwitchMap in angular2 resolver

I have a requirement of displaying modal popup based on warning message inside angular resolver. I am making a service call to API and using combineLatest and SwitchMap returning multiple responses. I need to display modal popup based on API service…