Skip to content

Commit 024a427

Browse files
committed
Change '(() => Subscription, Observable[R])' to 'ConnectableObservable[R]'
1 parent 29f564a commit 024a427

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

language-adaptors/rxjava-scala/src/examples/scala/rx/lang/scala/examples/RxScalaDemo.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ class RxScalaDemo extends JUnitSuite {
312312

313313
@Test def exampleWithReplay() {
314314
val numbers = Observable.interval(1000 millis).take(6)
315-
val (startFunc, sharedNumbers) = numbers.replay
315+
val sharedNumbers = numbers.replay
316316
sharedNumbers.subscribe(n => println(s"subscriber 1 gets $n"))
317-
startFunc()
317+
sharedNumbers.connect
318318
// subscriber 2 subscribes later but still gets all numbers
319319
doLater(3500 millis, () => { sharedNumbers.subscribe(n => println(s"subscriber 2 gets $n")) })
320320
waitFor(sharedNumbers)

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,9 @@ trait Observable[+T]
215215
* @return a pair of a start function and an [[rx.lang.scala.Observable]] such that when the start function
216216
* is called, the Observable starts to push results into the specified Subject
217217
*/
218-
def multicast[R >: T](subject: rx.lang.scala.Subject[R]): (() => Subscription, Observable[R]) = {
218+
def multicast[R >: T](subject: rx.lang.scala.Subject[R]): ConnectableObservable[R] = {
219219
val s: rx.subjects.Subject[_ >: T, _<: R] = subject.asJavaSubject
220-
val javaCO: rx.observables.ConnectableObservable[R] = asJavaObservable.multicast(s)
221-
(() => javaCO.connect(), toScalaObservable(javaCO))
220+
new ConnectableObservable[R](asJavaObservable.multicast(s))
222221
}
223222

224223
/**
@@ -1032,9 +1031,8 @@ trait Observable[+T]
10321031
* @return a pair of a start function and an [[rx.lang.scala.Observable]] such that when the start function
10331032
* is called, the Observable starts to emit items to its [[rx.lang.scala.Observer]]s
10341033
*/
1035-
def replay: (() => Subscription, Observable[T]) = {
1036-
val javaCO = asJavaObservable.replay()
1037-
(() => javaCO.connect(), toScalaObservable[T](javaCO))
1034+
def replay: ConnectableObservable[T] = {
1035+
new ConnectableObservable[T](asJavaObservable.replay())
10381036
}
10391037

10401038
/**

0 commit comments

Comments
 (0)