Last active
December 15, 2018 15:37
-
-
Save MartinHH/6977ee66963e438eaf9a4d8f6314893b to your computer and use it in GitHub Desktop.
RxScala vs Monix(3.0.0-RC2): behavior of SwitchMap when "parent" Observable completes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example | |
import monix.execution.Ack | |
object Main { | |
def main(args: Array[String]): Unit = { | |
implicit val s = monix.execution.schedulers.TestScheduler() | |
val parent = monix.reactive.subjects.PublishSubject[Int]() | |
val child = monix.reactive.subjects.PublishSubject[Int]() | |
val o = parent.switchMap(x => child.map(x -> _)) | |
o.subscribe{ u => | |
print(u) | |
Ack.Continue | |
} | |
parent.onNext(1) | |
child.onNext(1) | |
parent.onComplete() | |
child.onNext(2) | |
// prints "(1, 1)" - in RxScala, this would print "(1,1)(1,2)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment