1
1
/**
2
2
* Copyright 2013 Netflix, Inc.
3
- *
3
+ *
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
6
6
* You may obtain a copy of the License at
7
- *
7
+ *
8
8
* http://www.apache.org/licenses/LICENSE-2.0
9
- *
9
+ *
10
10
* Unless required by applicable law or agreed to in writing, software
11
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
16
17
- package rx .lang .scala {
17
+ package rx .lang .scala
18
18
19
- /**
19
+ /**
20
20
* Subscriptions are returned from all `Observable.subscribe` methods to allow unsubscribing.
21
21
*
22
22
* This interface is the equivalent of `IDisposable` in the .NET Rx implementation.
23
23
*/
24
- trait Subscription {
24
+ trait Subscription {
25
25
26
- val asJavaSubscription : rx.Subscription
26
+ val asJavaSubscription : rx.Subscription
27
27
28
- /**
29
- * Call this method to stop receiving notifications on the Observer that was registered when
30
- * this Subscription was received.
31
- */
32
- def unsubscribe (): Unit = asJavaSubscription.unsubscribe()
28
+ /**
29
+ * Call this method to stop receiving notifications on the Observer that was registered when
30
+ * this Subscription was received.
31
+ */
32
+ def unsubscribe (): Unit = asJavaSubscription.unsubscribe()
33
33
34
- /**
35
- * Checks if the subscription is unsubscribed.
36
- */
37
- def isUnsubscribed : Boolean
38
- }
34
+ /**
35
+ * Checks if the subscription is unsubscribed.
36
+ */
37
+ def isUnsubscribed : Boolean
39
38
}
40
39
41
- package rx .lang .scala .subscriptions {
42
-
43
- import rx .lang .scala .Subscription
44
- import java .util .concurrent .atomic .AtomicBoolean
45
-
46
-
47
40
object Subscription {
48
-
41
+ import java .util .concurrent .atomic .AtomicBoolean
42
+ import rx .lang .scala .subscriptions ._
43
+
49
44
/**
50
- * Creates an [[rx.lang.scala.Subscription ]] from an[[rx.Subscription ]].
45
+ * Creates an [[rx.lang.scala.Subscription ]] from an [[rx.Subscription ]].
51
46
*/
52
47
def apply (subscription : rx.Subscription ): Subscription = {
53
- subscription match {
54
- case x : rx.subscriptions.BooleanSubscription => new BooleanSubscription (x)
55
- case x : rx.subscriptions.CompositeSubscription => new CompositeSubscription (x)
56
- case x : rx.subscriptions.MultipleAssignmentSubscription => new MultipleAssignmentSubscription (x)
57
- case x : rx.subscriptions.SerialSubscription => new SerialSubscription (x)
58
- case x : rx.Subscription => Subscription { x.unsubscribe() }
59
- }
48
+ subscription match {
49
+ case x : rx.subscriptions.BooleanSubscription => new BooleanSubscription (x)
50
+ case x : rx.subscriptions.CompositeSubscription => new CompositeSubscription (x)
51
+ case x : rx.subscriptions.MultipleAssignmentSubscription => new MultipleAssignmentSubscription (x)
52
+ case x : rx.subscriptions.SerialSubscription => new SerialSubscription (x)
53
+ case x : rx.Subscription => Subscription { x.unsubscribe() }
54
+ }
60
55
}
61
56
62
57
/**
63
58
* Creates an [[rx.lang.scala.Subscription ]] that invokes the specified action when unsubscribed.
64
59
*/
65
- def apply (u : => Unit ): Subscription = {
66
- new Subscription () {
60
+ def apply (u : => Unit ): Subscription = {
61
+ new Subscription () {
67
62
68
63
private val unsubscribed = new AtomicBoolean (false )
69
64
def isUnsubscribed = unsubscribed.get()
@@ -73,7 +68,7 @@ object Subscription {
73
68
}
74
69
}
75
70
}
76
- }
71
+
77
72
}
78
73
79
74
0 commit comments