daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top