File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ object ImplicitFunctionConversions {
29
29
30
30
implicit def scalaFunction1ToOnSubscribeFunc [T ](f : rx.lang.scala.Observer [T ] => Subscription ) =
31
31
new rx.Observable .OnSubscribeFunc [T ] {
32
- def onSubscribe (obs : Observer [_ >: T ]): Subscription = {
33
- f(obs)
32
+ def onSubscribe (obs : Observer [_ >: T ]): rx. Subscription = {
33
+ f(obs).asJava
34
34
}
35
35
}
36
36
Original file line number Diff line number Diff line change @@ -35,8 +35,20 @@ package object scala {
35
35
36
36
type Observer [- T ] = rx.Observer [_ >: T ]
37
37
type Scheduler = rx.Scheduler
38
- type Subscription = rx.Subscription
39
38
39
+ /**
40
+ * Subscriptions are returned from all Observable.subscribe methods to allow unsubscribing.
41
+ *
42
+ * This interface is the RxJava equivalent of IDisposable in Microsoft's Rx implementation.
43
+ */
44
+ implicit class Subscription (val asJava : rx.Subscription ) extends AnyVal {
45
+ /**
46
+ * Call this to stop receiving notifications on the Observer that was registered when
47
+ * this Subscription was received.
48
+ */
49
+ def unsubscribe (): Unit = asJava.unsubscribe()
50
+ }
51
+
40
52
}
41
53
42
54
/*
You can’t perform that action at this time.
0 commit comments