-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Closed
Description
When I unsubscribe from an Observable which emits the last value of an infinite stream, I expect to get no element. This is the case in C#:
var o = Observable.Interval(TimeSpan.FromMilliseconds(200)).TakeLast(1);
var s = o.Subscribe(i => Console.WriteLine("Interesting: Infinity = " + i));
Thread.Sleep(1000);
s.Dispose();
Thread.Sleep(1000);
Console.WriteLine("Press any key...");
Console.ReadKey();
outputs
Press any key...
But with RxJava, it's different (note that Scala's takeRight calls Java's takeLast):
val o = Observable.interval(200 millis).takeRight(1)
val s = o.subscribe(i => println(s"Interesting: Infinity = $i"))
Thread.sleep(1000)
s.unsubscribe()
Thread.sleep(1000)
outputs
Interesting: Infinity = 4
Metadata
Metadata
Assignees
Labels
No labels