Questions tagged [rx-scala]

RxScala – Reactive Extensions for Scala

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

RxScala is open sourced and available under the Apache License, Version 2.0

91 questions
0
votes
1 answer

Scala Observable Creation Blocks My Futures

I am wanting to process ea. query fetch (potentially multiple fetches per query) asynchronously. In order to do this, I pass the processing function (which returns a Future) to my query method to call it for ea. fetch. I don't know beforehand the…
0
votes
1 answer

Scala future-derived observable callbacks not getting called

Using scala 2.11.7, rxscala_2.11 0.25.0, rxjava 1.0.16, my oddFutures callbacks don't get called in AsyncDisjointedChunkMultiprocessing.process(): package jj.async import scala.concurrent.Future import scala.concurrent.ExecutionContext import…
juanchito
  • 493
  • 1
  • 5
  • 16
0
votes
1 answer

`delay` on `interval` will throw `NoSuchElementException`?

Some simple rxscala code: val s = Observable.interval(Duration("100 millis")) .zip(Seq(1, 2, 3)).map(_._2).delay(Duration("2 s")) println(s.toBlocking.toList) When run it, it throws exception: Exception in thread "main"…
Freewind
  • 193,756
  • 157
  • 432
  • 708
0
votes
0 answers

How to get historical data from a PublishSubject?

How to get all historical data from a PublishSubject? val ob = PublishSubject[Int]() ob.subscribe(x => println("a: " + x)) ob.onNext(1) ob.subscribe(x => println("b: " + x)) ob.onNext(2) It prints: a: 1 a: 2 b: 2 You can see there is no b: 1…
Freewind
  • 193,756
  • 157
  • 432
  • 708
0
votes
0 answers

Combining Observables in RxScala

i was wondering if someone can give me some hints here. I am learning RxScala and i have the following exercise to do: - Implement an observable object that emits an event every 5 seconds and every 12 seconds I was wondering if the following code…
user1068378
  • 333
  • 2
  • 12
0
votes
0 answers

RxScala behave differently in worksheet and after compile

I was playing around with RxScala and Subject in scala worksheet. But something weird happened. as we can see, subscription c also get numbers and output them. After that, I find subscription c is var not val. So, I change the declare. And get…
Nks Sai
  • 23
  • 2
0
votes
1 answer

How to cause a backpressure exception zipping two Observables?

I'm trying to write a test to see the use of onBackPressureDrop in RxScala. I'm zipping a fast Obserable with a slow one, with a simple zipping function. The curious thing is that the same example in RxJava produces the exception but with RxScala…
juanpavergara
  • 1,511
  • 1
  • 11
  • 22
0
votes
1 answer

RxJava: Blocking on an observable after subscription?

I have a special need for an observable. Usually, my observables run in a different thread. But, sometimes they need to block another thread in the middle of subscription. Something the way a future behaves. An example: val o = Observable.create(/*…
0
votes
1 answer

How to observe on reverse dependency order?

I'd like to observe a tree of objects, in reverse dependency order, but do not know what combinators to use. The specific case is iterating through AWS Resources in order for deletion, for example deleting S3 Objects before deleting their S3…
Julio Faerman
  • 13,228
  • 9
  • 57
  • 75
0
votes
1 answer

RxScala Observables with replay

I'm trying to understand replay in RxScala. I create an observable like this: lazy val toyObservable : Observable[Int] = { val coldObservable : Observable[Int] = intPerSecond val hotObservable : ConnectableObservable[Int] =…
thund
  • 1,842
  • 2
  • 21
  • 31
0
votes
1 answer

Scala Reactive Extensions Observable apply Method

From the API docs of Rx Observable in scala: http://reactivex.io/rxscala/scaladoc/#rx.lang.scala.Observable There are two apply methods, one that takes a Subscriber and the other that takes an Observer. What is the difference between these two apply…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
1 answer

RxScala Observer and Subscription

I'm just getting started with RxScala and came across a few examples. I understand that there is an Observable contract in which the Observer trait is defined as follows: trait Observer[T] { def onNext(event: T): Unit def onError(error:…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
1 answer

RxScala buffer elements

I have application where I need parse strings and I use for it RxScala. My code: import java.util.concurrent.TimeUnit import rx.lang.scala.Subject import rx.lang.scala.schedulers.NewThreadScheduler import rx.lang.scala.subjects.{SerializedSubject,…
krynio
  • 2,442
  • 26
  • 30
0
votes
2 answers

Implement a recurring job repeating not more than once per second

Suppose we have something like this: while (true) { val job = Future { doSomething(); 1 } val timeout = Future { Thread.sleep(1000); 2 } val both = for (j <- job; t <- timeout) { println("Done") } Await.result(both) } What is the…
Tair
  • 3,779
  • 2
  • 20
  • 33
0
votes
1 answer

Reactive Extensions (RxScala) equivalent of fold ifEmpty

I was wondering if there is any equivalent of the Scala fold ifEmpty function that exists for collections and options: fold[B](ifEmpty: => B)(f: (A) => B) This function is powerful in that it can transform between different monad types - for…
mixja
  • 6,977
  • 3
  • 32
  • 34