@@ -8,35 +8,98 @@ import scala.annotation.implicitNotFound
8
8
9
9
10
10
11
+ /** A reactive map is a reactive counterpart of a mutable map.
12
+ *
13
+ * Calling the `react` method of the `RMap` type returns.
14
+ *
15
+ * @tparam K the type of the keys in the reactive map
16
+ * @tparam V the type of the values in the reactive map
17
+ */
11
18
trait RMap [@ spec(Int , Long , Double ) K , V <: AnyRef ] extends RContainer [(K , V )] {
12
19
20
+ /** The special value that represents an absence of the value
21
+ * under the specified key.
22
+ *
23
+ * @returns the nil value
24
+ */
25
+ def nil : V
26
+
27
+ /** Returns the value associated with the specified key or throws an exception if the key is not present.
28
+ *
29
+ * @param k the key
30
+ * @returns the value associated with the key
31
+ */
13
32
def apply (k : K ): V
14
33
34
+ /** Returns the value associated with the specified key or a nil value if the key is not present.
35
+ *
36
+ * @param k the key
37
+ * @returns the value associated with the key, or a nil value
38
+ */
39
+ def applyOrNil (k : K ): V
40
+
41
+ /** Optionally returns the value associated with the key, if it is present.
42
+ *
43
+ * @param k the key
44
+ * @returns the optional value associated with the key
45
+ */
46
+ def get (k : K ): Option [V ]
47
+
48
+ /** Returns the view over pairs in this map.
49
+ */
15
50
def entries : PairContainer [K , V ]
16
51
52
+ /** Returns the view over keys in this map.
53
+ */
17
54
def keys : RContainer [K ]
18
55
56
+ /** Returns the view over values in this map.
57
+ *
58
+ * This method may only be used if the reactive map is injective,
59
+ * that is, no two keys are mapped into the same value.
60
+ */
19
61
def values : RContainer [V ]
20
62
63
+ /** Returns the lifted view of the reactive map, used to obtain reactive values in this map.
64
+ */
21
65
def react : RMap .Lifted [K , V ]
22
66
23
67
}
24
68
25
69
26
70
object RMap {
27
71
72
+ /** Factory method for default reactive map creation.
73
+ */
28
74
def apply [@ spec(Int , Long , Double ) K , V >: Null <: AnyRef ](implicit can : RHashMap .Can [K , V ]) = new RHashMap [K , V ]
29
75
76
+ /** Reactive builder factory, automatically used for transforming containers into reactive maps.
77
+ */
30
78
implicit def factory [@ spec(Int , Long , Double ) K , V >: Null <: AnyRef ] = new RBuilder .Factory [(K , V ), RMap [K , V ]] {
31
79
def apply () = RHashMap [K , V ]
32
80
}
33
81
82
+ /** Reactive pair builder factory, automatically used for transforming pair containers into reactive maps.
83
+ */
34
84
implicit def pairFactory [@ spec(Int , Long , Double ) K , V >: Null <: AnyRef ] = new PairBuilder .Factory [K , V , RMap [K , V ]] {
35
85
def apply () = RHashMap [K , V ]
36
86
}
37
87
88
+ /** Lifted view of the reactive map.
89
+ */
38
90
trait Lifted [@ spec(Int , Long , Double ) K , V <: AnyRef ] extends RContainer .Lifted [(K , V )] {
91
+ /** The original reactive map container.
92
+ */
39
93
val container : RMap [K , V ]
94
+
95
+ /** Returns the reactive value associated with the key.
96
+ *
97
+ * The reactive value emits an event whenever a new value
98
+ * is subsequently assigned to the specified key.
99
+ *
100
+ * @param key the key
101
+ * @returns the reactive containing all the values assigned to the key
102
+ */
40
103
def apply (key : K ): Reactive [V ]
41
104
}
42
105
0 commit comments