Guest User

Untitled

a guest
Dec 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. package example
  2.  
  3. import monix.execution.Ack
  4.  
  5. object scala {
  6.  
  7. def main(args: Array[String]): Unit = {
  8. implicit val s = monix.execution.schedulers.TestScheduler()
  9. val parent = monix.reactive.subjects.PublishSubject[Int]()
  10. val child = monix.reactive.subjects.PublishSubject[Int]()
  11.  
  12. val o = parent.switchMap(x => child.map(x -> _))
  13.  
  14. o.subscribe{ u =>
  15. print(u)
  16. Ack.Continue
  17. }
  18.  
  19. parent.onNext(1)
  20. child.onNext(1)
  21.  
  22. parent.onComplete()
  23. child.onNext(2)
  24. // prints "(1, 1)" - in RxScala, this would print "(1,1)(1,2)"
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment