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
1
vote
0 answers

Observable's events not received

I have a variable called responses of type Observable[Try[Int]] that emits either: Success(n), where n is a natural number or Failure(Exception) I am summing the values of this observable like this: val sum = responses.foldLeft(0) { (acc, tn) => …
bsky
  • 19,326
  • 49
  • 155
  • 270
1
vote
1 answer

Subscription without any parameters

I need to write some RxScala code that creates an Observable from a text field in Scala Swing. After looking on Github, I wrote this code, which seems to work: def textValues: Observable[String] = Observable.create[String](observer => { …
bsky
  • 19,326
  • 49
  • 155
  • 270
1
vote
2 answers

Observables created at time interval

I was looking at the RxScala observables which are created at a given time interval: val periodic: Observable[Long] = Observable.interval(100 millis) periodic.foreach(x => println(x)) If I put this in a worksheet, I get this result: periodic:…
bsky
  • 19,326
  • 49
  • 155
  • 270
1
vote
1 answer

Calling (overloaded) RxJava functions from Scala

I wanted to create an Observable from an array of Observables like this: package rxtest import concurrent._ import concurrent.ExecutionContext.Implicits.global import rx.lang.scala._ import rx.lang.scala.JavaConversions._ import…
user2595776
  • 304
  • 1
  • 10
1
vote
1 answer

How to use custom Scheduler in RxScala?

I attempt with val executors = Executors.newSingleThreadExecutor() val scheduler = Schedulers.from(executors) Observable.just[Int](1,2,3).subscribeOn(scheduler) output a error Error:(103, 43) type mismatch; found : rx.Scheduler required:…
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
1
vote
1 answer

How to cancel a mapped Observable with specify condition at RxScala/Java?

original observable ------a-------b-------c----------d-------->.... mapped observable -----A-------B(finish) Simple code as this: val original = Observable.just('a', 'b', 'c', 'd') val mapped = original.map(x => x.toUpper) //how to let…
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
1
vote
1 answer

RxJava/RxScala backpressure using request

I am having an issue using RxJava backpressure. Basically, I have one producer that produces more items than the consumer can handle and want to have some buffer queue to handle only items that I can deal with, and request when I complete some of…
proximator
  • 687
  • 6
  • 18
1
vote
0 answers

How to unsubscribe all observers from the observable side?

With rxscala, we can subscribe on the observables like this: val stream = Observable.just(1, 2, 3) stream.subscribe(x => doSomething(x)) stream.subscribe(x => doSomething(x)) stream.subscribe(x => doSomething(x)) stream.subscribe(x =>…
Freewind
  • 193,756
  • 157
  • 432
  • 708
1
vote
1 answer

How to construct a Observable with custom numbers and different delays?

In order to test my reactive program with rxscala, I need to construct such an Observable: val numberStream: Observable[Int] = Observable.???() which publishes number 1 then waits for 1s publishes number 4 then waits for 3s publishes number…
Freewind
  • 193,756
  • 157
  • 432
  • 708
1
vote
2 answers

Terminate Observable by timeout

I'm trying to limit life of observable by timeout: def doLongOperation() = { Thread.sleep(duration) "OK" } def firstStep = Observable.create( (observer: Observer[String]) => { observer.onNext(doLongOperation()) …
Nyavro
  • 8,806
  • 2
  • 26
  • 33
1
vote
1 answer

How to update an observable manually?

I'm newbie to reactivex and rxscala, and can create an Observable like this: val observable = Observable[String] { subscriber => subscriber.onNext("something") } I can put new strings to the subscriber inside the Observable.apply. Is it…
Freewind
  • 193,756
  • 157
  • 432
  • 708
1
vote
1 answer

How do you use RxScala in Intellij Idea 14?

I've just recently started coding in Scala and I want to start working with RxScala but I haven't been able to figure out how to import it into Intellij. Does anyone know how to do this, I've spent the last few hours trying to figure this out and…
Ryan Wilson
  • 1,743
  • 3
  • 15
  • 26
1
vote
1 answer

Database Polling using RxScala

TableEntriesI'm starting out with RxScala and I'm trying to come up with a polling mechanism that checks the database for every interval (say 20 seconds), to check if there was any change in some of the rows in the table. object MyDatabaseService…
joesan
  • 13,963
  • 27
  • 95
  • 232
1
vote
1 answer

Problems when merging a sampled Observable

I'm using rx-scala, which is a subproject of rx-java. I'll be using Scala syntax and hope that everyone understands. I'm encountering odd behavior, and I don't know whether it's a bug or misusage of rx operators on my behalf. Problem Statement I…
ziggystar
  • 28,410
  • 9
  • 72
  • 124
1
vote
2 answers

RxScala: How to keep the thread doing Observable.interval alive?

I am trying to write a simple RxScala program: import rx.lang.scala.Observable import scala.concurrent.duration.DurationInt import scala.language.{implicitConversions, postfixOps} object Main { def main(args: Array[String]): Unit = { val o =…
Binil Thomas
  • 13,699
  • 10
  • 57
  • 70