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

Angular / Firestore - Anything after combineLatest / switchMap being ignored

I have a function that's uploading two images to firebase storage. The uploads work perfectly fine. const smallTaskRef = this.storage.upload(thumbPath, results.thumb); const largeTaskRef = this.storage.upload(largePath, results.large); However,…
0
votes
3 answers

Make nested Http calls inside switchMap

if (this.role === 'admin' || this.role === 'superadmin') { this.organizationService.getDropdownOrganizations().pipe( tap(availableOrganizations => { this.availableOrganizations = availableOrganizations; }), …
Rishav Tandon
  • 793
  • 4
  • 8
0
votes
1 answer

Pass the action value in effects for switchMap via both another switchMap and filter?

There is a code @Effect() myEffect$ = this.actions$.pipe( ofType(MyActions.doSomething), tap(() => this.store.dispatch(MyActions.doSomething2())), switchMap(action => { that works. I need to inject a filter right before tap.…
Haradzieniec
  • 9,086
  • 31
  • 117
  • 212
0
votes
2 answers

The result of my mapped observable is... an observable? (after running through a switchMap)

I was expecting the result of a mapped observable to be the entity that I selected from a prior chained observable, but instead it appears to be the observable itself. However, I can't subscribe to it or map it because it says it's of (custom) type…
jugglervr
  • 315
  • 1
  • 14
0
votes
1 answer

switchMap is not cancelling previous HTTP call

one of angular service method(http call) created with switchMap operator,so it can reject/cancel the previous rest API calls if new one arrived. it is working fine and make a backend call but it not reject any BE call but it sequentially calling…
0
votes
2 answers

using pipe async always stucks on loading

I'm joining multiple observables in one global joined$ observable using switchMap and combineLatest this is the component TS file: export class ProgressComponent implements OnInit{ user: User; joined$: Observable; constructor( …
Ilyas Ghomrani
  • 408
  • 6
  • 26
0
votes
1 answer

Different between of(...) and [...] in switchMap in effect

For example we have some effect: ... switchMap(() => of(action1, action2)) ... and ... switchMap(() => [action1, action2]) ... Do we have any differents?
artart
  • 3
  • 2
0
votes
1 answer

RxJS make multiple AJAX requests then get a new list with another AJAX request

The goal is to make multiple save request and then get a new list using another ajax request. I have the following that appears to be what I want but was wondering if there was a better way of(1,2,3) .pipe( concatMap(vals => vals), …
Rob Stone
  • 3
  • 1
0
votes
2 answers

Cannot destructure property 'uid' of 'object null' as it is null

So I had a function in Angular named appUser$, the error said "Cannot destructure property 'uid' of 'object null' as it is null." get appUser$(): Observable { return this.user$.pipe( switchMap(({uid})=>…
0
votes
1 answer

firebase.auth().createUserWithEmailAndPassword() - completes before a using any other rxJs operators

I am using angularFireAuth for authentication and the firestore as the DB. My use-case is pretty simple: register a new user with email and password using firebase JS SDK methods. On successful registration, save the user's info in the firestore…
Irshad
  • 1,016
  • 11
  • 30
0
votes
1 answer

How to execute switchMap and tap rxJS functions from Jasmine test?

I have the following test let component: MyComponent; let fixture: ComponentFixture; let loader: HarnessLoader; const items: MyItem[] = [ { id: '66249535-31bf-41f3-8f55-8a14877c6d7e', status: 'New' } ]; …
Josh
  • 718
  • 2
  • 15
  • 38
0
votes
3 answers

How to cancel in flight pending http api calls?

I have a button on my web page on pressing which an http api call is made. It takes some time to get the response and reflect in the page. So is there a way to cancel in flight pending http requests to avoid multiple api calls in case the user…
SanDash
  • 733
  • 1
  • 6
  • 15
0
votes
2 answers

Angular 2+ swtichMap doesn't work correctly

I have a button witch makes a request to the server. And i'm using the switchMap operator with subject for preventing multiple pending requests. //service public getPhotos(): Observable { return this.http.get(`url`) } //component …
0
votes
2 answers

Rxjs switchMap + toArray

I am having a problem with rxjs. I have a function that should do this: Having a list of group ids. In the example: of(['1', '2']) For each one of them fetch the list of chats Return merged list of chats When execution reaches toArray nothing…
adrisons
  • 3,443
  • 3
  • 32
  • 48
0
votes
1 answer

Angular9/rxjs6.5: How to Transform an Array of Observable Object Array to an Observable Object Property Array?

I'm using Angular(9) Powered Bootstrap (ng-bootstrap 6.1) and am providing ngbTypeahead with an Observable like so: search = (text$: Observable) => { return text$.pipe( debounceTime(200), distinctUntilChanged(), …
CAK2
  • 1,892
  • 1
  • 15
  • 17