Questions tagged [concatmap]

concatMap is a function from RxJava library, which returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source Observable, where that function returns an Observable, and then emitting the items that result from concatinating those resulting Observables.

concatMap is a function from RxJava library, which returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source Observable, where that function returns an Observable, and then emitting the items that result from concatinating those resulting Observables.

67 questions
66
votes
7 answers

What is the difference between concatMap and flatMap in RxJava

It seems that these 2 functions are pretty similar. They have same signature (accepting rx.functions.Func1> func), and their marble diagrams look exactly same. Can't paste the pics here, but here's one…
Haspemulator
  • 11,050
  • 9
  • 49
  • 76
8
votes
2 answers

Using concatMap to run a Single before running another observable

Android Studio 3.1 RC 2 kotlin 1.2.30 The signature of the fetchMessage in Java Single fetchMessage(final String Id); The kotlin code fun translate(Id: String): Completable { return repository.fetchMessage(Id) …
ant2009
  • 27,094
  • 154
  • 411
  • 609
7
votes
2 answers

Interrupt a single observable in concatMap

I use concatMap to process a stream of items one at a time with a long running operation. At some point I need to "interrupt" this long running operation, but only for the current item: @Test public void main() throws InterruptedException { …
tir38
  • 9,810
  • 10
  • 64
  • 107
6
votes
2 answers

RXJS Chain dependent observables sequentially, but getting each emission for a progress bar

I'm facing a problem, and I've been trying to find a solution using RxJs, but can't seem to find one that fits it... I have 3 different REST requests, that will be called sequentially, and each of them needs the response of the previous one as an…
Bryan Lee
  • 150
  • 1
  • 8
6
votes
3 answers

Angular - RxJS ConcatMap - Return Data From Both Service Calls

Probably a basic question, but I have an Angular app that makes a backend service call to retrieve some data and then uses that data to make another backend service call. The second service call is dependent on the first completing successfully, so…
RookieMcRookie
  • 403
  • 2
  • 5
  • 7
4
votes
1 answer

How to implement in angular multiple sequential Http requests in a loop (each new request depends of the previous results)

I have a grid that contains heavy data to be loaded and so the loading time became not manageable. The solution I found was do a sequential number of http requests, each one retrieving batches of 100 rows, till fulfill all data on the grid. I know…
4
votes
1 answer

ConcatMap interupted when error in one observable

I have the following code: Observable.from(modifiedNodes) .concatMap(node => { return this.Model.setData(node); }) .subscribe(() => { NodeSaved++; } If setData throws an error for any intermediate node, the next…
pratRockss
  • 455
  • 8
  • 25
3
votes
3 answers

RxJS: execute concatMap i parallel

Is it possible to execute a high-order observable in parallel, but still preserve the order when merging the results? I have something looking like this: invoker$: Observable; fetch: (index: number) => Observable; invoker$ .pipe( …
Mikkel R. Lund
  • 2,336
  • 1
  • 31
  • 44
3
votes
1 answer

RxJava - flatmap vs concatMap - why is ordering the same on subscription?

According to this thread conCatMap and flatmap only differ by the order in which items are emitted. So i did a test and created a simple stream of integers and wanted to see in what order they would be emitted. I made a small observable that would…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
2
votes
1 answer

how to pass data between concatmap in RXJS Angular

I have a pipe on a observable, the code is like below: .pipe( concatMap(() => this.security.getUser()), tap((partyId) => { if (!partyId) { window.location.assign(`${environment.redirectURL1}/dashboard/login`); …
2
votes
2 answers

complete dynamic array observables one by one (concatMap)

I am making a chat app and I would like to save messages in the correct order. Imagine, I would have a static number of messages // 4 messages. array of static length: 4 chatMessages: string[] = ['hello', 'world', 'and', 'stack overflow members'];…
Sergej
  • 2,030
  • 1
  • 18
  • 28
2
votes
1 answer

RXJS - Are nested concapMap equivalent to sequential concatMap?

When using RXJS I ask myself if nested concatMap are equivalent to sequential ones. Consider the following example: observable1.pipe( concatMap(result1 => observable2.pipe( concatMap(result2 => observable3.pipe( concatMap(result3…
Florian
  • 1,142
  • 1
  • 9
  • 21
2
votes
1 answer

rxjs concatMap does not seem to be called

The 2nd concatMap does not get called. this.apiService.get() .pipe( concatMap((data: MyModel) => { if (data) { // the following returns a MyModel Observable …
Antediluvian
  • 653
  • 1
  • 6
  • 18
2
votes
0 answers

mock Observable concatMap function inside Unit test (Angular 5)

Edit: I figured it out, the problem is spyOn will make the function it spy on to return undefined, need to call and.callThough explicitly. I'm trying to test my component, which uses ngrx store. I'm stubbing my store in that unit test like…
2
votes
3 answers

RxJava flatMapIterable with concatMap

I have 2 retrofit calls I need to make A & B: (A): returns an ArrayList (B): gets the result of (A) which is an ArrayList. (B) iterates through the ArrayList and makes a retrofit call using each and combines the resulting data into a final…
Mike6679
  • 5,547
  • 19
  • 63
  • 108
1
2 3 4 5