Skip to content

Commit c8bf9e6

Browse files
committed
Add share to RxScala
1 parent 48275f0 commit c8bf9e6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,22 @@ trait Observable[+T]
14571457
toScalaObservable[T](asJavaObservable.cache())
14581458
}
14591459

1460+
/**
1461+
* Returns a new [[Observable]] that multicasts (shares) the original [[Observable]]. As long a
1462+
* there is more than 1 [[Subscriber]], this [[Observable]] will be subscribed and emitting data.
1463+
* When all subscribers have unsubscribed it will unsubscribe from the source [[Observable]].
1464+
*
1465+
* This is an alias for `publish().refCount()`
1466+
*
1467+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/publishRefCount.png">
1468+
*
1469+
* @return a [[Observable]] that upon connection causes the source Observable to emit items to its [[Subscriber]]s
1470+
* @since 0.19
1471+
*/
1472+
def share: Observable[T] = {
1473+
toScalaObservable[T](asJavaObservable.share())
1474+
}
1475+
14601476
/**
14611477
* Returns an Observable that emits a Boolean that indicates whether the source Observable emitted a
14621478
* specified item.

0 commit comments

Comments
 (0)