You can't - not to the observable you created. What you need is a Subject
, using which you can emit values.
Subject
is basically both an Observable
and an Observer
.
For example:
import rx.lang.scala._
import rx.lang.scala.subjects._
val subject = ReplaySubject[Int]()
val initial = Observable(1,2,3,4)
val target = initial ++ subject // concat the observables
val subscription1 = target subscribe(println(_))
val subscription2 = target subscribe(println(_))
subject.onNext(4) // emit '4'
subject.onNext(6) // emit '6'