Hello, I'd expect sliding to open a new window when the first observable emits an object. I'd also expect that window to be closed when the closing observable emits an object.
val source = Observable.interval(100.milliseconds).share
val open = Subject[String]()
val close = Subject[String]()
open.subscribe(it => println("open publishes", it))
close.subscribe(it => println("close publishes", it))
source.subscribe(it => println("source", it))
source.subscribe(it => if (it == 2) open.onNext("YO"))
source.subscribe(it => if (it == 6) close.onNext("OY"))
source.sliding(open)((_) => Observable.just(1))
.flatMap(it => it.toList)
.subscribe(it => println("window: ", it))
UPDATE: The code does work IF I replace Subject[String] with Subject[Object] for both close and open. Now I'm even more confused. Am I supposed to always use Object for signalling opening and closing events? At the moment the signature for the method is Observable[Any] and not Observable[Object].
Hello, I'd expect
sliding
to open a new window when the first observable emits an object. I'd also expect that window to be closed when the closing observable emits an object.produces the following output:
Instead I'd expect
(window: ,List(3, 4, 5, 6))
to appear just after(close publishes,OY)
.The same code works as expected in RxJS: https://jsfiddle.net/c7Lpj3a1/188/
UPDATE: The code does work IF I replace
Subject[String]
withSubject[Object]
for bothclose
andopen
. Now I'm even more confused. Am I supposed to always useObject
for signalling opening and closing events? At the moment the signature for the method isObservable[Any]
and notObservable[Object]
.