Questions tagged [mergemap]

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

signature: mergeMap(project: function: Observable, resultSelector: function: any, concurrent: number): Observable

mergeMap offers full control over asynchronicity - both when new elements are created/emitted and how many elements from the source stream should be processed concurrently. For example: assume a source stream emitted 10 elements but maxConcurrency is set to 2 then two first elements will be processed immediately and the rest 8 buffered. Once one of the processed elements is completed, the next element from the source stream will be processed and so on.

54 questions
1
vote
2 answers

RXJS MergeMap not getting executed

In the below code, the execution never goes to mergemap. Looking for some help with correcting this code. Requirement is, once i get response from getBns method, i need to perform some operation with response and then using the tap operator to…
Deadpool_er
  • 215
  • 4
  • 20
1
vote
1 answer

Caching observables causing problem with mergeMap

I have a caching method in a container: get(): Observable { if (!this.get$) { this.get$ = merge( this.behaviorSubject.asObservable(), this._config.get().pipe(shareReplay(1), tap(x => this.behaviorSubject.next(x)))); } …
1
vote
1 answer

Handling two HTTP requests (Angular + RxJS)

This is my first angular project, and I'm still not familiar that well with Observables and RxJS. In my project, at first I want to fetch all notifications with get request. After that, I want to take id of the last notification, so I could send…
user13067004
  • 131
  • 1
  • 1
  • 5
1
vote
2 answers

RxJS logic which solves a filter/merge issue

This is more a logical problem then a RxJS problem, I guess, but I do not get it how to solve it. [input 1] From a cities stream, I will receive 1 or 2 objects (cities1 or cities2 are test fixtures). 1 object if their is only one language available,…
Jonas
  • 23
  • 5
1
vote
0 answers

Create map of values of two maps with common keys java

I have a Map and Map. I want Map for the keys which have the same key. E.g. Employee emp1 = new Employee("bla1"); Employee emp2 = new Employee("bla2"); Map nameEmployee = new…
Garima Natany
  • 53
  • 1
  • 4
1
vote
1 answer

Multiple API calls based on page size in Angular

API call - getList() => returns 1000 numbers Say 1,2,3...1000 Make 20 API calls by taking above top 20 results I am trying to do something like this this.http.get('urlService').mergeMap((ids: number[]) => this.getItems(ids.slice(0, 20))). …
Aagam Doshi
  • 155
  • 2
  • 14
1
vote
3 answers

How to return result of inner observable in route resolver Angular

I am trying write what seems like a simple method to fetch a users profile details for my Angular app and load that data before navigating to the profile page using a resolver. . The resolver doesn't complete even though there a no errors This is my…
1
vote
1 answer

Using return result from api requests with Forkjoin with mergeMap and pipe

I would like to use return results from multiple api requests and reuse it as a parameter for the second api request and the second api request return a result i have to reuse in the third api request ! The problem is i only can return one api…
1
vote
1 answer

mergeMap not returning data when inner observable is empty/ api returns no data

I am trying to merge three observables and when the inner observable does not have any data, the mergeMap is not returning any data. I want to be able to continue the process even if one of the inner observable is empty. How do I handle this…
mywn9
  • 107
  • 12
1
vote
2 answers

Wait for all observables in mergeMap to complete before emitting a custom value

I want to process a list of observables concurrently using flatMap and then to emit a single empty value when all inner observables are processed. Is there an elegant way to achieve this, i.e. using a single operator? Here's the example: const { of,…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
1
vote
2 answers

Rxjs mergeMap: Concat 2 related Api Requests

I have two api requests, the second one depends on the first one. The first request gets an array of 3 facilities. After this i need to do an api request for each facility to get an image which i need. I need the uuid of the facilities. I thought…
keschra
  • 289
  • 1
  • 3
  • 17
1
vote
2 answers

Merge map Angular

Can you tell me what am I doing wrong ? this.scheduleService.GetZones(environment.systemId) .pipe( mergeMap((zone: Zone) => { return this.dashboardService.GetLatestMeasurementValue(environment.systemId, zone.sensorId) }) …
Matei Emil
  • 65
  • 9
1
vote
1 answer

Mergemap error with sending request from server

I have a angular application and I am doing a post request with a service call. But I get an error. But the service call send the request. So it is a very misleading error. This is the method I have: sendEcheq(patientId: string) { if…
user12296049
1
vote
1 answer

Angular 8 - Assign class property inside MergeMap

I'm using MergeMap to make nested http calls in my Angular 8 app. However, my requirement is to assign a property of my model inside MergeMap as shown in below code. onFormSubmit(author, email, website, comment) { let user = new…
Dash
  • 804
  • 1
  • 9
  • 16
1
vote
1 answer

Filter array observable by promise

I have An array of objects A function permission(obj): Promise How can I filter this array by the promise? I've tried numerous things, and the closest I got was of(arr).pipe( switchMap(items => from(items) .pipe( …
Daniel
  • 10,641
  • 12
  • 47
  • 85