Questions tagged [reactivex]

ReactiveX is a library for composing asynchronous and event-based programs by using observable sequences.

From reactivex.io:

It extends the observer pattern to support sequences of data and/or events and adds operators that allow you to compose sequences together declaratively while abstracting away concerns about things like low-level threading, synchronization, thread-safety, concurrent data structures, and non-blocking I/O.

688 questions
7
votes
1 answer

When should I use blockingGet?

I am using RxJava a lot for work and seen some examples of calling a method which returns an Observable or Single and then calling blockingGet on it to use the results in a different . I was thinking this might be a misuse of the library and the…
godzsa
  • 2,105
  • 4
  • 34
  • 56
7
votes
4 answers

mergeMap does not exist on type observable

I am trying to use mergeMap in rxjs6 and i am getting this error: Property 'mergeMap' does not exist on type 'Observable<{}>' I have tried import 'rxjs/add/operator/mergeMap'; and it is not working. What am i doing wrong? import {from, Observable}…
prolink007
  • 33,872
  • 24
  • 117
  • 185
7
votes
1 answer

RxPy: Sort hot observable between (slow) scan executions

TL;DR I'm looking for help to implement the marble diagram below. The intention is to sort the non-sorted values to the extent possible without waiting time between scan executions. I'm not asking for a full implementation. Any guidance will be…
raul.vila
  • 1,984
  • 1
  • 11
  • 24
7
votes
2 answers

How can I apply timed back pressure in RxJS5?

Imagine I have the following code: let a = Rx.Observable.of(1, 2, 3) let b = Observable.zip(a, a, (a, b) => a + b) b.forEach(t => console.log(t)) This immediately outputs the results. Now, how do I put a timed delay between each message as a way of…
Hugo Sereno Ferreira
  • 8,600
  • 7
  • 46
  • 92
7
votes
2 answers

Make observable to behave like promise in RxJS?

Considering I have a function which calls a server and returns user data through Observable: getUserById (id: number): Observable { return this.http.get('/users/' + id) .map(response => response.json()) ; } How do I make it to behave…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
7
votes
3 answers

How to wait for RxPy parallel threads to complete

Based on this excellent SO answer I can get multiple tasks working in parallel in RxPy, my problem is how do you wait for them to all complete? I know using threading I can do .join() but there doesn't seem to be any such option with Rx Schedulers.…
phdesign
  • 2,019
  • 21
  • 18
7
votes
3 answers

Cycling dependencies between streams in reactive programming

Dabbling in reactive programming, I often encounter situations where two streams depend on each other. What is an idiomatic way to solve these cases? A minimal example: There are buttons A and B, both display a value. Clicking on A must increment…
Steve
  • 374
  • 1
  • 4
  • 13
7
votes
1 answer

RxSwift - .subscribe vs .subscribeNext what is the difference?

What is the difference betweeen these two operators ? http://reactivex.io dont mention .subscribeNext at all.
Alexey K
  • 6,537
  • 18
  • 60
  • 118
7
votes
2 answers

ReactiveX : Error Handling that doesn't destroy observable

Its unclear how to propagate errors to subscribers in REactiveX such that the Observable doesn't get destroyed. Example observable.onNext(1); observable.onNext(2); observable.onError("Nope"); observable.onNext(3);<
John Twigg
  • 7,171
  • 4
  • 20
  • 20
7
votes
1 answer

How long did it take to run an Observable using RxJava (ReactiveX)?

I'm using java ReactiveX (RxJava) in scala Play Framework 2.5 to communicate with couchbase asynchronously I would like to know how long it took for my observable to run? I define my observable using the code below. def get(id: String) :…
Francis
  • 379
  • 5
  • 21
7
votes
1 answer

Re-subscribing to an Observable after error

I feel like I'm beginning to get the hang of RxSwift - however I've just hit a roadblock. Here's an object I've built for a demo (I've simplified it before posting to SO). My issue is, when there's a network error during the upload process, all of…
jonlambert
  • 432
  • 7
  • 14
6
votes
1 answer

Why use the RxJS .asObservable() getter/factory function pattern?

In a lot of codebases using RxJS I seem to come across the pattern of exposing private Subjects as Observables via a getter or normal getObservable() function. My question is not why .asObservable() is used, but instead why it seems so commonly…
timmwagener
  • 2,368
  • 2
  • 19
  • 27
6
votes
3 answers

RxJS: An Observable that takes its own old value as input

I'm trying to implement something like this: // This obviously doesn't work, because we try to refer to `a` before it exists. // c and m are some Observables. const aSampled = a.pipe( rxjs.operators.sample(c), …
user619051
  • 87
  • 5
6
votes
3 answers

Confusing behavior of rxjs operator `delay`

I'm a bit confused about the rxjs operator delay. When I test it with a fake observable created with from, then I only see an initial delay: const { from } = Rx; const { delay, tap } = RxOperators; from([1, 2, 3, 4]).pipe( tap(console.log), …
Good Night Nerd Pride
  • 8,245
  • 4
  • 49
  • 65
6
votes
1 answer

How to call an async coroutine periodically using an RxPY interval observable?

I need to create an Observable stream which emits the result of a async coroutine at regular intervals. intervalRead is a function which returns an Observable, and takes as parameters the interval rate and an async coroutine function fun, which…
tomasdussa
  • 63
  • 1
  • 3