@@ -19,7 +19,8 @@ object RxImplicits {
19
19
import java .{ lang => jlang }
20
20
import language .implicitConversions
21
21
22
- import rx .Observable
22
+ import rx .{ Observable , Observer , Subscription }
23
+ import rx .Observable .OnSubscribeFunc
23
24
import rx .observables .BlockingObservable
24
25
import rx .util .functions ._
25
26
@@ -56,7 +57,7 @@ object RxImplicits {
56
57
}
57
58
58
59
/**
59
- * Converts a function shaped ilke compareTo into the equivalent Rx Func2
60
+ * Converts a function shaped like compareTo into the equivalent Rx Func2
60
61
*/
61
62
implicit def convertComparisonFuncToRxFunc2 [A ](f : (A , A ) => Int ): Func2 [A , A , jlang.Integer ] =
62
63
new Func2 [A , A , jlang.Integer ] {
@@ -100,6 +101,11 @@ object RxImplicits {
100
101
def call (a : A , b : B , c : C , d : D ) = f(a, b, c, d)
101
102
}
102
103
104
+ implicit def onSubscribeFunc [A ](f : (Observer [_ >: A ]) => Subscription ): OnSubscribeFunc [A ] =
105
+ new OnSubscribeFunc [A ] {
106
+ override def call (a : Observer [_ >: A ]) = f(a)
107
+ }
108
+
103
109
/**
104
110
* This implicit class implements all of the methods necessary for including Observables in a
105
111
* for-comprehension. Note that return type is always Observable, so that the ScalaObservable
@@ -131,7 +137,9 @@ class UnitTestSuite extends JUnitSuite {
131
137
import org .mockito .Mockito ._
132
138
import org .mockito .{ MockitoAnnotations , Mock }
133
139
import rx .{ Notification , Observer , Observable , Subscription }
140
+ import rx .Observable .OnSubscribeFunc
134
141
import rx .observables .GroupedObservable
142
+ import rx .subscriptions .Subscriptions
135
143
import collection .mutable .ArrayBuffer
136
144
import collection .JavaConverters ._
137
145
@@ -175,7 +183,6 @@ class UnitTestSuite extends JUnitSuite {
175
183
}
176
184
177
185
// tests of static methods
178
-
179
186
@ Test def testSingle {
180
187
assertEquals(1 , Observable .from(1 ).toBlockingObservable.single)
181
188
}
@@ -208,6 +215,11 @@ class UnitTestSuite extends JUnitSuite {
208
215
case ex : Throwable => fail(" Caught unexpected exception " + ex.getCause + " , expected IllegalStateException" )
209
216
}
210
217
}
218
+
219
+ @ Test def testCreateFromOnSubscribeFunc {
220
+ val created = Observable .create((o : Observer [_ >: Integer ]) => Subscriptions .empty)
221
+ // no assertions on subscription, just testing the implicit
222
+ }
211
223
212
224
@ Test def testFromJavaInterop {
213
225
val observable = Observable .from(List (1 , 2 , 3 ).asJava)
0 commit comments