Skip to content

Commit 0c7dc06

Browse files
AppliedDualitybenjchristensen
authored andcommitted
Notification constructors
Implicit conversions
1 parent 3fe31fb commit 0c7dc06

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,21 @@ object ImplicitFunctionConversions {
3939
}
4040
}
4141

42+
implicit def toJavaNotification[T](s: Notification[T]): rx.Notification[_ <: T] = s.asJava
43+
implicit def toScalaNotification[T](s: rx.Notification[_ <: T]): Notification[T] = Notification(s)
44+
4245
implicit def toJavaSubscription(s: Subscription): rx.Subscription = s.asJavaSubscription
4346
implicit def toScalaSubscription(s: rx.Subscription): Subscription = Subscription(s)
4447

4548
implicit def scalaSchedulerToJavaScheduler(s: Scheduler): rx.Scheduler = s.asJavaScheduler
4649
implicit def javaSchedulerToScalaScheduler(s: rx.Scheduler): Scheduler = Scheduler(s)
4750

4851
implicit def toJavaObserver[T](s: Observer[T]): rx.Observer[_ >: T] = s.asJavaObserver
49-
implicit def toScalaObserver[T](s: rx.Observer[T]): Observer[T] = Observer(s)
52+
implicit def toScalaObserver[T](s: rx.Observer[_ >: T]): Observer[T] = Observer(s)
5053

5154
implicit def toJavaObservable[T](s: Observable[T]): rx.Observable[_ <: T] = s.asJavaObservable
52-
implicit def toScalaObservable[T](s: rx.Observable[T]): Observable[T] = Observable(s)
53-
55+
implicit def toScalaObservable[T](s: rx.Observable[_ <: T]): Observable[T] = Observable(s)
56+
5457
implicit def scalaFunction1ToOnSubscribeFunc[T](f: rx.lang.scala.Observer[T] => Subscription) =
5558
new rx.Observable.OnSubscribeFunc[T] {
5659
def onSubscribe(obs: rx.Observer[_ >: T]): rx.Subscription = {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ object Notification {
3636
}
3737

3838
object OnNext {
39+
40+
def apply[T](value: T): Notification[T] = {
41+
Notification(new rx.Notification[T](value))
42+
}
43+
3944
def unapply[U](n: Notification[U]): Option[U] = n match {
4045
case n2: OnNext[U] => Some(n.asJava.getValue)
4146
case _ => None
@@ -47,6 +52,11 @@ object Notification {
4752
}
4853

4954
object OnError {
55+
56+
def apply[T](error: Throwable): Notification[T] = {
57+
Notification(new rx.Notification[T](error))
58+
}
59+
5060
def unapply[U](n: Notification[U]): Option[Throwable] = n match {
5161
case n2: OnError[U] => Some(n2.asJava.getThrowable)
5262
case _ => None
@@ -56,6 +66,11 @@ object Notification {
5666
class OnCompleted[T](val asJava: rx.Notification[_ <: T]) extends Notification[T] {}
5767

5868
object OnCompleted {
69+
70+
def apply[T](): Notification[T] = {
71+
Notification(new rx.Notification())
72+
}
73+
5974
def unapply[U](n: Notification[U]): Option[Unit] = n match {
6075
case n2: OnCompleted[U] => Some()
6176
case _ => None

0 commit comments

Comments
 (0)