Showing
5 changed files
with
137 additions
and
124 deletions
@@ -118,8 +118,8 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -118,8 +118,8 @@ class _RxImpl<T> implements RxInterface<T> { | ||
118 | // ignore: avoid_equals_and_hash_code_on_mutable_classes | 118 | // ignore: avoid_equals_and_hash_code_on_mutable_classes |
119 | bool operator ==(dynamic o) { | 119 | bool operator ==(dynamic o) { |
120 | // Todo, find a common implementation for the hashCode of different Types. | 120 | // Todo, find a common implementation for the hashCode of different Types. |
121 | - if (o is T) return _value == o; | ||
122 | - if (o is RxInterface<T>) return _value == o.value; | 121 | + if (o is T) return value == o; |
122 | + if (o is RxInterface<T>) return value == o.value; | ||
123 | return false; | 123 | return false; |
124 | } | 124 | } |
125 | 125 | ||
@@ -165,6 +165,7 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -165,6 +165,7 @@ class _RxImpl<T> implements RxInterface<T> { | ||
165 | } | 165 | } |
166 | 166 | ||
167 | Stream<T> get stream => subject.stream; | 167 | Stream<T> get stream => subject.stream; |
168 | + | ||
168 | StreamSubscription<T> listen(void Function(T) onData, | 169 | StreamSubscription<T> listen(void Function(T) onData, |
169 | {Function onError, void Function() onDone, bool cancelOnError}) => | 170 | {Function onError, void Function() onDone, bool cancelOnError}) => |
170 | stream.listen(onData, onError: onError, onDone: onDone); | 171 | stream.listen(onData, onError: onError, onDone: onDone); |
@@ -3,13 +3,13 @@ part of 'rx_impl.dart'; | @@ -3,13 +3,13 @@ part of 'rx_impl.dart'; | ||
3 | /// Base Rx class for all num Rx's. | 3 | /// Base Rx class for all num Rx's. |
4 | class _BaseRxNum<T extends num> extends _RxImpl<T> { | 4 | class _BaseRxNum<T extends num> extends _RxImpl<T> { |
5 | /// Addition operator. */ | 5 | /// Addition operator. */ |
6 | - num operator +(num other) => _value + other; | 6 | + num operator +(num other) => value + other; |
7 | 7 | ||
8 | /// Subtraction operator. | 8 | /// Subtraction operator. |
9 | - num operator -(num other) => _value - other; | 9 | + num operator -(num other) => value - other; |
10 | 10 | ||
11 | /// Multiplication operator. | 11 | /// Multiplication operator. |
12 | - num operator *(num other) => _value * other; | 12 | + num operator *(num other) => value * other; |
13 | 13 | ||
14 | /// Euclidean modulo operator. | 14 | /// Euclidean modulo operator. |
15 | /// | 15 | /// |
@@ -24,10 +24,10 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -24,10 +24,10 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
24 | /// The sign of the returned value `r` is always positive. | 24 | /// The sign of the returned value `r` is always positive. |
25 | /// | 25 | /// |
26 | /// See [remainder] for the remainder of the truncating division. | 26 | /// See [remainder] for the remainder of the truncating division. |
27 | - num operator %(num other) => _value % other; | 27 | + num operator %(num other) => value % other; |
28 | 28 | ||
29 | /// Division operator. | 29 | /// Division operator. |
30 | - double operator /(num other) => _value / other; | 30 | + double operator /(num other) => value / other; |
31 | 31 | ||
32 | /// Truncating division operator. | 32 | /// Truncating division operator. |
33 | /// | 33 | /// |
@@ -36,10 +36,10 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -36,10 +36,10 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
36 | /// | 36 | /// |
37 | /// If both operands are [int]s then `a ~/ b` performs the truncating | 37 | /// If both operands are [int]s then `a ~/ b` performs the truncating |
38 | /// integer division. | 38 | /// integer division. |
39 | - int operator ~/(num other) => _value ~/ other; | 39 | + int operator ~/(num other) => value ~/ other; |
40 | 40 | ||
41 | /// Negate operator. | 41 | /// Negate operator. |
42 | - num operator -() => -_value; | 42 | + num operator -() => -value; |
43 | 43 | ||
44 | /// Returns the remainder of the truncating division of `this` by [other]. | 44 | /// Returns the remainder of the truncating division of `this` by [other]. |
45 | /// | 45 | /// |
@@ -47,40 +47,40 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -47,40 +47,40 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
47 | /// `this == (this ~/ other) * other + r`. | 47 | /// `this == (this ~/ other) * other + r`. |
48 | /// As a consequence the remainder `r` has the same sign as the divider | 48 | /// As a consequence the remainder `r` has the same sign as the divider |
49 | /// `this`. | 49 | /// `this`. |
50 | - num remainder(num other) => _value.remainder(other); | 50 | + num remainder(num other) => value.remainder(other); |
51 | 51 | ||
52 | /// Relational less than operator. | 52 | /// Relational less than operator. |
53 | - bool operator <(num other) => _value < other; | 53 | + bool operator <(num other) => value < other; |
54 | 54 | ||
55 | /// Relational less than or equal operator. | 55 | /// Relational less than or equal operator. |
56 | - bool operator <=(num other) => _value <= other; | 56 | + bool operator <=(num other) => value <= other; |
57 | 57 | ||
58 | /// Relational greater than operator. | 58 | /// Relational greater than operator. |
59 | - bool operator >(num other) => _value > other; | 59 | + bool operator >(num other) => value > other; |
60 | 60 | ||
61 | /// Relational greater than or equal operator. | 61 | /// Relational greater than or equal operator. |
62 | - bool operator >=(num other) => _value >= other; | 62 | + bool operator >=(num other) => value >= other; |
63 | 63 | ||
64 | /// True if the number is the double Not-a-Number value; otherwise, false. | 64 | /// True if the number is the double Not-a-Number value; otherwise, false. |
65 | - bool get isNaN => _value.isNaN; | 65 | + bool get isNaN => value.isNaN; |
66 | 66 | ||
67 | /// True if the number is negative; otherwise, false. | 67 | /// True if the number is negative; otherwise, false. |
68 | /// | 68 | /// |
69 | /// Negative numbers are those less than zero, and the double `-0.0`. | 69 | /// Negative numbers are those less than zero, and the double `-0.0`. |
70 | - bool get isNegative => _value.isNegative; | 70 | + bool get isNegative => value.isNegative; |
71 | 71 | ||
72 | /// True if the number is positive infinity or negative infinity; otherwise, | 72 | /// True if the number is positive infinity or negative infinity; otherwise, |
73 | /// false. | 73 | /// false. |
74 | - bool get isInfinite => _value.isInfinite; | 74 | + bool get isInfinite => value.isInfinite; |
75 | 75 | ||
76 | /// True if the number is finite; otherwise, false. | 76 | /// True if the number is finite; otherwise, false. |
77 | /// | 77 | /// |
78 | /// The only non-finite numbers are NaN, positive infinity, and | 78 | /// The only non-finite numbers are NaN, positive infinity, and |
79 | /// negative infinity. | 79 | /// negative infinity. |
80 | - bool get isFinite => _value.isFinite; | 80 | + bool get isFinite => value.isFinite; |
81 | 81 | ||
82 | /// Returns the absolute value of this [num]. | 82 | /// Returns the absolute value of this [num]. |
83 | - num abs() => _value.abs(); | 83 | + num abs() => value.abs(); |
84 | 84 | ||
85 | /// Returns minus one, zero or plus one depending on the sign and | 85 | /// Returns minus one, zero or plus one depending on the sign and |
86 | /// numerical value of the number. | 86 | /// numerical value of the number. |
@@ -98,7 +98,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -98,7 +98,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
98 | /// n == n.sign * n.abs() | 98 | /// n == n.sign * n.abs() |
99 | /// | 99 | /// |
100 | /// for all numbers `n` (except NaN, because NaN isn't `==` to itself). | 100 | /// for all numbers `n` (except NaN, because NaN isn't `==` to itself). |
101 | - num get sign => _value.sign; | 101 | + num get sign => value.sign; |
102 | 102 | ||
103 | /// Returns the integer closest to `this`. | 103 | /// Returns the integer closest to `this`. |
104 | /// | 104 | /// |
@@ -106,23 +106,23 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -106,23 +106,23 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
106 | /// `(3.5).round() == 4` and `(-3.5).round() == -4`. | 106 | /// `(3.5).round() == 4` and `(-3.5).round() == -4`. |
107 | /// | 107 | /// |
108 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 108 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
109 | - int round() => _value.round(); | 109 | + int round() => value.round(); |
110 | 110 | ||
111 | /// Returns the greatest integer no greater than `this`. | 111 | /// Returns the greatest integer no greater than `this`. |
112 | /// | 112 | /// |
113 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 113 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
114 | - int floor() => _value.floor(); | 114 | + int floor() => value.floor(); |
115 | 115 | ||
116 | /// Returns the least integer no smaller than `this`. | 116 | /// Returns the least integer no smaller than `this`. |
117 | /// | 117 | /// |
118 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 118 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
119 | - int ceil() => _value.ceil(); | 119 | + int ceil() => value.ceil(); |
120 | 120 | ||
121 | /// Returns the integer obtained by discarding any fractional | 121 | /// Returns the integer obtained by discarding any fractional |
122 | /// digits from `this`. | 122 | /// digits from `this`. |
123 | /// | 123 | /// |
124 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 124 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
125 | - int truncate() => _value.truncate(); | 125 | + int truncate() => value.truncate(); |
126 | 126 | ||
127 | /// Returns the double integer value closest to `this`. | 127 | /// Returns the double integer value closest to `this`. |
128 | /// | 128 | /// |
@@ -140,7 +140,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -140,7 +140,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
140 | /// The result is always a double. | 140 | /// The result is always a double. |
141 | /// If this is a numerically large integer, the result may be an infinite | 141 | /// If this is a numerically large integer, the result may be an infinite |
142 | /// double. | 142 | /// double. |
143 | - double roundToDouble() => _value.roundToDouble(); | 143 | + double roundToDouble() => value.roundToDouble(); |
144 | 144 | ||
145 | /// Returns the greatest double integer value no greater than `this`. | 145 | /// Returns the greatest double integer value no greater than `this`. |
146 | /// | 146 | /// |
@@ -153,7 +153,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -153,7 +153,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
153 | /// The result is always a double. | 153 | /// The result is always a double. |
154 | /// If this is a numerically large integer, the result may be an infinite | 154 | /// If this is a numerically large integer, the result may be an infinite |
155 | /// double. | 155 | /// double. |
156 | - double floorToDouble() => _value.floorToDouble(); | 156 | + double floorToDouble() => value.floorToDouble(); |
157 | 157 | ||
158 | /// Returns the least double integer value no smaller than `this`. | 158 | /// Returns the least double integer value no smaller than `this`. |
159 | /// | 159 | /// |
@@ -166,7 +166,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -166,7 +166,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
166 | /// The result is always a double. | 166 | /// The result is always a double. |
167 | /// If this is a numerically large integer, the result may be an infinite | 167 | /// If this is a numerically large integer, the result may be an infinite |
168 | /// double. | 168 | /// double. |
169 | - double ceilToDouble() => _value.ceilToDouble(); | 169 | + double ceilToDouble() => value.ceilToDouble(); |
170 | 170 | ||
171 | /// Returns the double integer value obtained by discarding any fractional | 171 | /// Returns the double integer value obtained by discarding any fractional |
172 | /// digits from the double value of `this`. | 172 | /// digits from the double value of `this`. |
@@ -181,7 +181,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -181,7 +181,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
181 | /// The result is always a double. | 181 | /// The result is always a double. |
182 | /// If this is a numerically large integer, the result may be an infinite | 182 | /// If this is a numerically large integer, the result may be an infinite |
183 | /// double. | 183 | /// double. |
184 | - double truncateToDouble() => _value.truncateToDouble(); | 184 | + double truncateToDouble() => value.truncateToDouble(); |
185 | 185 | ||
186 | /// Returns this [num] clamped to be in the range [lowerLimit]-[upperLimit]. | 186 | /// Returns this [num] clamped to be in the range [lowerLimit]-[upperLimit]. |
187 | /// | 187 | /// |
@@ -192,17 +192,17 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -192,17 +192,17 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
192 | /// The arguments [lowerLimit] and [upperLimit] must form a valid range where | 192 | /// The arguments [lowerLimit] and [upperLimit] must form a valid range where |
193 | /// `lowerLimit.compareTo(upperLimit) <= 0`. | 193 | /// `lowerLimit.compareTo(upperLimit) <= 0`. |
194 | num clamp(num lowerLimit, num upperLimit) => | 194 | num clamp(num lowerLimit, num upperLimit) => |
195 | - _value.clamp(lowerLimit, upperLimit); | 195 | + value.clamp(lowerLimit, upperLimit); |
196 | 196 | ||
197 | /// Truncates this [num] to an integer and returns the result as an [int]. */ | 197 | /// Truncates this [num] to an integer and returns the result as an [int]. */ |
198 | - int toInt() => _value.toInt(); | 198 | + int toInt() => value.toInt(); |
199 | 199 | ||
200 | /// Return this [num] as a [double]. | 200 | /// Return this [num] as a [double]. |
201 | /// | 201 | /// |
202 | /// If the number is not representable as a [double], an | 202 | /// If the number is not representable as a [double], an |
203 | /// approximation is returned. For numerically large integers, the | 203 | /// approximation is returned. For numerically large integers, the |
204 | /// approximation may be infinite. | 204 | /// approximation may be infinite. |
205 | - double toDouble() => _value.toDouble(); | 205 | + double toDouble() => value.toDouble(); |
206 | 206 | ||
207 | /// Returns a decimal-point string-representation of `this`. | 207 | /// Returns a decimal-point string-representation of `this`. |
208 | /// | 208 | /// |
@@ -227,7 +227,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -227,7 +227,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
227 | /// 10000000000000000.toStringAsFixed(4); // 10000000000000000.0000 | 227 | /// 10000000000000000.toStringAsFixed(4); // 10000000000000000.0000 |
228 | /// 5.25.toStringAsFixed(0); // 5 | 228 | /// 5.25.toStringAsFixed(0); // 5 |
229 | String toStringAsFixed(int fractionDigits) => | 229 | String toStringAsFixed(int fractionDigits) => |
230 | - _value.toStringAsFixed(fractionDigits); | 230 | + value.toStringAsFixed(fractionDigits); |
231 | 231 | ||
232 | /// Returns an exponential string-representation of `this`. | 232 | /// Returns an exponential string-representation of `this`. |
233 | /// | 233 | /// |
@@ -248,7 +248,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -248,7 +248,7 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
248 | /// 123456.toStringAsExponential(3); // 1.235e+5 | 248 | /// 123456.toStringAsExponential(3); // 1.235e+5 |
249 | /// 123.toStringAsExponential(0); // 1e+2 | 249 | /// 123.toStringAsExponential(0); // 1e+2 |
250 | String toStringAsExponential([int fractionDigits]) => | 250 | String toStringAsExponential([int fractionDigits]) => |
251 | - _value.toStringAsExponential(fractionDigits); | 251 | + value.toStringAsExponential(fractionDigits); |
252 | 252 | ||
253 | /// Converts `this` to a double and returns a string representation with | 253 | /// Converts `this` to a double and returns a string representation with |
254 | /// exactly [precision] significant digits. | 254 | /// exactly [precision] significant digits. |
@@ -267,48 +267,48 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | @@ -267,48 +267,48 @@ class _BaseRxNum<T extends num> extends _RxImpl<T> { | ||
267 | /// 0.00000012345.toStringAsPrecision(15); // 1.23450000000000e-7 | 267 | /// 0.00000012345.toStringAsPrecision(15); // 1.23450000000000e-7 |
268 | /// 0.0000012345.toStringAsPrecision(15); // 0.00000123450000000000 | 268 | /// 0.0000012345.toStringAsPrecision(15); // 0.00000123450000000000 |
269 | String toStringAsPrecision(int precision) => | 269 | String toStringAsPrecision(int precision) => |
270 | - _value.toStringAsPrecision(precision); | 270 | + value.toStringAsPrecision(precision); |
271 | } | 271 | } |
272 | 272 | ||
273 | class RxNum extends _BaseRxNum<num> {} | 273 | class RxNum extends _BaseRxNum<num> {} |
274 | 274 | ||
275 | class RxDouble extends _BaseRxNum<double> { | 275 | class RxDouble extends _BaseRxNum<double> { |
276 | RxDouble([double initial]) { | 276 | RxDouble([double initial]) { |
277 | - _value = initial; | 277 | + value = initial; |
278 | } | 278 | } |
279 | 279 | ||
280 | /// Addition operator. | 280 | /// Addition operator. |
281 | - double operator +(num other) => _value + other; | 281 | + double operator +(num other) => value + other; |
282 | 282 | ||
283 | /// Subtraction operator. | 283 | /// Subtraction operator. |
284 | - double operator -(num other) => _value - other; | 284 | + double operator -(num other) => value - other; |
285 | 285 | ||
286 | /// Multiplication operator. | 286 | /// Multiplication operator. |
287 | - double operator *(num other) => _value * other; | 287 | + double operator *(num other) => value * other; |
288 | 288 | ||
289 | - double operator %(num other) => _value % other; | 289 | + double operator %(num other) => value % other; |
290 | 290 | ||
291 | /// Division operator. | 291 | /// Division operator. |
292 | - double operator /(num other) => _value / other; | 292 | + double operator /(num other) => value / other; |
293 | 293 | ||
294 | /// Truncating division operator. | 294 | /// Truncating division operator. |
295 | /// | 295 | /// |
296 | /// The result of the truncating division `a ~/ b` is equivalent to | 296 | /// The result of the truncating division `a ~/ b` is equivalent to |
297 | /// `(a / b).truncate()`. | 297 | /// `(a / b).truncate()`. |
298 | - int operator ~/(num other) => _value ~/ other; | 298 | + int operator ~/(num other) => value ~/ other; |
299 | 299 | ||
300 | /// Negate operator. */ | 300 | /// Negate operator. */ |
301 | - double operator -() => -_value; | 301 | + double operator -() => -value; |
302 | 302 | ||
303 | /// Returns the absolute value of this [double]. | 303 | /// Returns the absolute value of this [double]. |
304 | - double abs() => _value.abs(); | 304 | + double abs() => value.abs(); |
305 | 305 | ||
306 | /// Returns the sign of the double's numerical value. | 306 | /// Returns the sign of the double's numerical value. |
307 | /// | 307 | /// |
308 | /// Returns -1.0 if the value is less than zero, | 308 | /// Returns -1.0 if the value is less than zero, |
309 | /// +1.0 if the value is greater than zero, | 309 | /// +1.0 if the value is greater than zero, |
310 | /// and the value itself if it is -0.0, 0.0 or NaN. | 310 | /// and the value itself if it is -0.0, 0.0 or NaN. |
311 | - double get sign => _value.sign; | 311 | + double get sign => value.sign; |
312 | 312 | ||
313 | /// Returns the integer closest to `this`. | 313 | /// Returns the integer closest to `this`. |
314 | /// | 314 | /// |
@@ -316,23 +316,23 @@ class RxDouble extends _BaseRxNum<double> { | @@ -316,23 +316,23 @@ class RxDouble extends _BaseRxNum<double> { | ||
316 | /// `(3.5).round() == 4` and `(-3.5).round() == -4`. | 316 | /// `(3.5).round() == 4` and `(-3.5).round() == -4`. |
317 | /// | 317 | /// |
318 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 318 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
319 | - int round() => _value.round(); | 319 | + int round() => value.round(); |
320 | 320 | ||
321 | /// Returns the greatest integer no greater than `this`. | 321 | /// Returns the greatest integer no greater than `this`. |
322 | /// | 322 | /// |
323 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 323 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
324 | - int floor() => _value.floor(); | 324 | + int floor() => value.floor(); |
325 | 325 | ||
326 | /// Returns the least integer no smaller than `this`. | 326 | /// Returns the least integer no smaller than `this`. |
327 | /// | 327 | /// |
328 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 328 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
329 | - int ceil() => _value.ceil(); | 329 | + int ceil() => value.ceil(); |
330 | 330 | ||
331 | /// Returns the integer obtained by discarding any fractional | 331 | /// Returns the integer obtained by discarding any fractional |
332 | /// digits from `this`. | 332 | /// digits from `this`. |
333 | /// | 333 | /// |
334 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. | 334 | /// If `this` is not finite (`NaN` or infinity), throws an [UnsupportedError]. |
335 | - int truncate() => _value.truncate(); | 335 | + int truncate() => value.truncate(); |
336 | 336 | ||
337 | /// Returns the integer double value closest to `this`. | 337 | /// Returns the integer double value closest to `this`. |
338 | /// | 338 | /// |
@@ -346,7 +346,7 @@ class RxDouble extends _BaseRxNum<double> { | @@ -346,7 +346,7 @@ class RxDouble extends _BaseRxNum<double> { | ||
346 | /// and `-0.0` is therefore considered closer to negative numbers than `0.0`. | 346 | /// and `-0.0` is therefore considered closer to negative numbers than `0.0`. |
347 | /// This means that for a value, `d` in the range `-0.5 < d < 0.0`, | 347 | /// This means that for a value, `d` in the range `-0.5 < d < 0.0`, |
348 | /// the result is `-0.0`. | 348 | /// the result is `-0.0`. |
349 | - double roundToDouble() => _value.roundToDouble(); | 349 | + double roundToDouble() => value.roundToDouble(); |
350 | 350 | ||
351 | /// Returns the greatest integer double value no greater than `this`. | 351 | /// Returns the greatest integer double value no greater than `this`. |
352 | /// | 352 | /// |
@@ -355,7 +355,7 @@ class RxDouble extends _BaseRxNum<double> { | @@ -355,7 +355,7 @@ class RxDouble extends _BaseRxNum<double> { | ||
355 | /// | 355 | /// |
356 | /// For the purpose of rounding, `-0.0` is considered to be below `0.0`. | 356 | /// For the purpose of rounding, `-0.0` is considered to be below `0.0`. |
357 | /// A number `d` in the range `0.0 < d < 1.0` will return `0.0`. | 357 | /// A number `d` in the range `0.0 < d < 1.0` will return `0.0`. |
358 | - double floorToDouble() => _value.floorToDouble(); | 358 | + double floorToDouble() => value.floorToDouble(); |
359 | 359 | ||
360 | /// Returns the least integer double value no smaller than `this`. | 360 | /// Returns the least integer double value no smaller than `this`. |
361 | /// | 361 | /// |
@@ -364,7 +364,7 @@ class RxDouble extends _BaseRxNum<double> { | @@ -364,7 +364,7 @@ class RxDouble extends _BaseRxNum<double> { | ||
364 | /// | 364 | /// |
365 | /// For the purpose of rounding, `-0.0` is considered to be below `0.0`. | 365 | /// For the purpose of rounding, `-0.0` is considered to be below `0.0`. |
366 | /// A number `d` in the range `-1.0 < d < 0.0` will return `-0.0`. | 366 | /// A number `d` in the range `-1.0 < d < 0.0` will return `-0.0`. |
367 | - double ceilToDouble() => _value.ceilToDouble(); | 367 | + double ceilToDouble() => value.ceilToDouble(); |
368 | 368 | ||
369 | /// Returns the integer double value obtained by discarding any fractional | 369 | /// Returns the integer double value obtained by discarding any fractional |
370 | /// digits from `this`. | 370 | /// digits from `this`. |
@@ -375,12 +375,12 @@ class RxDouble extends _BaseRxNum<double> { | @@ -375,12 +375,12 @@ class RxDouble extends _BaseRxNum<double> { | ||
375 | /// For the purpose of rounding, `-0.0` is considered to be below `0.0`. | 375 | /// For the purpose of rounding, `-0.0` is considered to be below `0.0`. |
376 | /// A number `d` in the range `-1.0 < d < 0.0` will return `-0.0`, and | 376 | /// A number `d` in the range `-1.0 < d < 0.0` will return `-0.0`, and |
377 | /// in the range `0.0 < d < 1.0` it will return 0.0. | 377 | /// in the range `0.0 < d < 1.0` it will return 0.0. |
378 | - double truncateToDouble() => _value.truncateToDouble(); | 378 | + double truncateToDouble() => value.truncateToDouble(); |
379 | } | 379 | } |
380 | 380 | ||
381 | class RxInt extends _BaseRxNum<int> { | 381 | class RxInt extends _BaseRxNum<int> { |
382 | RxInt([int initial]) { | 382 | RxInt([int initial]) { |
383 | - _value = initial; | 383 | + value = initial; |
384 | } | 384 | } |
385 | 385 | ||
386 | /// Bit-wise and operator. | 386 | /// Bit-wise and operator. |
@@ -391,7 +391,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -391,7 +391,7 @@ class RxInt extends _BaseRxNum<int> { | ||
391 | /// | 391 | /// |
392 | /// If both operands are negative, the result is negative, otherwise | 392 | /// If both operands are negative, the result is negative, otherwise |
393 | /// the result is non-negative. | 393 | /// the result is non-negative. |
394 | - int operator &(int other) => _value & other; | 394 | + int operator &(int other) => value & other; |
395 | 395 | ||
396 | /// Bit-wise or operator. | 396 | /// Bit-wise or operator. |
397 | /// | 397 | /// |
@@ -401,7 +401,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -401,7 +401,7 @@ class RxInt extends _BaseRxNum<int> { | ||
401 | /// | 401 | /// |
402 | /// If both operands are non-negative, the result is non-negative, | 402 | /// If both operands are non-negative, the result is non-negative, |
403 | /// otherwise the result is negative. | 403 | /// otherwise the result is negative. |
404 | - int operator |(int other) => _value | other; | 404 | + int operator |(int other) => value | other; |
405 | 405 | ||
406 | /// Bit-wise exclusive-or operator. | 406 | /// Bit-wise exclusive-or operator. |
407 | /// | 407 | /// |
@@ -411,7 +411,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -411,7 +411,7 @@ class RxInt extends _BaseRxNum<int> { | ||
411 | /// | 411 | /// |
412 | /// If the operands have the same sign, the result is non-negative, | 412 | /// If the operands have the same sign, the result is non-negative, |
413 | /// otherwise the result is negative. | 413 | /// otherwise the result is negative. |
414 | - int operator ^(int other) => _value ^ other; | 414 | + int operator ^(int other) => value ^ other; |
415 | 415 | ||
416 | /// The bit-wise negate operator. | 416 | /// The bit-wise negate operator. |
417 | /// | 417 | /// |
@@ -419,7 +419,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -419,7 +419,7 @@ class RxInt extends _BaseRxNum<int> { | ||
419 | /// the result is a number with the opposite bits set. | 419 | /// the result is a number with the opposite bits set. |
420 | /// | 420 | /// |
421 | /// This maps any integer `x` to `-x - 1`. | 421 | /// This maps any integer `x` to `-x - 1`. |
422 | - int operator ~() => ~_value; | 422 | + int operator ~() => ~value; |
423 | 423 | ||
424 | /// Shift the bits of this integer to the left by [shiftAmount]. | 424 | /// Shift the bits of this integer to the left by [shiftAmount]. |
425 | /// | 425 | /// |
@@ -431,7 +431,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -431,7 +431,7 @@ class RxInt extends _BaseRxNum<int> { | ||
431 | /// mask. | 431 | /// mask. |
432 | /// | 432 | /// |
433 | /// It is an error if [shiftAmount] is negative. | 433 | /// It is an error if [shiftAmount] is negative. |
434 | - int operator <<(int shiftAmount) => _value << shiftAmount; | 434 | + int operator <<(int shiftAmount) => value << shiftAmount; |
435 | 435 | ||
436 | /// Shift the bits of this integer to the right by [shiftAmount]. | 436 | /// Shift the bits of this integer to the right by [shiftAmount]. |
437 | /// | 437 | /// |
@@ -440,13 +440,13 @@ class RxInt extends _BaseRxNum<int> { | @@ -440,13 +440,13 @@ class RxInt extends _BaseRxNum<int> { | ||
440 | ///`pow(2, shiftIndex)`. | 440 | ///`pow(2, shiftIndex)`. |
441 | /// | 441 | /// |
442 | /// It is an error if [shiftAmount] is negative. | 442 | /// It is an error if [shiftAmount] is negative. |
443 | - int operator >>(int shiftAmount) => _value >> shiftAmount; | 443 | + int operator >>(int shiftAmount) => value >> shiftAmount; |
444 | 444 | ||
445 | /// Returns this integer to the power of [exponent] modulo [modulus]. | 445 | /// Returns this integer to the power of [exponent] modulo [modulus]. |
446 | /// | 446 | /// |
447 | /// The [exponent] must be non-negative and [modulus] must be | 447 | /// The [exponent] must be non-negative and [modulus] must be |
448 | /// positive. | 448 | /// positive. |
449 | - int modPow(int exponent, int modulus) => _value.modPow(exponent, modulus); | 449 | + int modPow(int exponent, int modulus) => value.modPow(exponent, modulus); |
450 | 450 | ||
451 | /// Returns the modular multiplicative inverse of this integer | 451 | /// Returns the modular multiplicative inverse of this integer |
452 | /// modulo [modulus]. | 452 | /// modulo [modulus]. |
@@ -454,7 +454,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -454,7 +454,7 @@ class RxInt extends _BaseRxNum<int> { | ||
454 | /// The [modulus] must be positive. | 454 | /// The [modulus] must be positive. |
455 | /// | 455 | /// |
456 | /// It is an error if no modular inverse exists. | 456 | /// It is an error if no modular inverse exists. |
457 | - int modInverse(int modulus) => _value.modInverse(modulus); | 457 | + int modInverse(int modulus) => value.modInverse(modulus); |
458 | 458 | ||
459 | /// Returns the greatest common divisor of this integer and [other]. | 459 | /// Returns the greatest common divisor of this integer and [other]. |
460 | /// | 460 | /// |
@@ -467,13 +467,13 @@ class RxInt extends _BaseRxNum<int> { | @@ -467,13 +467,13 @@ class RxInt extends _BaseRxNum<int> { | ||
467 | /// For any integer `x`, `x.gcd(x)` is `x.abs()`. | 467 | /// For any integer `x`, `x.gcd(x)` is `x.abs()`. |
468 | /// | 468 | /// |
469 | /// If both `this` and `other` is zero, the result is also zero. | 469 | /// If both `this` and `other` is zero, the result is also zero. |
470 | - int gcd(int other) => _value.gcd(other); | 470 | + int gcd(int other) => value.gcd(other); |
471 | 471 | ||
472 | /// Returns true if and only if this integer is even. | 472 | /// Returns true if and only if this integer is even. |
473 | - bool get isEven => _value.isEven; | 473 | + bool get isEven => value.isEven; |
474 | 474 | ||
475 | /// Returns true if and only if this integer is odd. | 475 | /// Returns true if and only if this integer is odd. |
476 | - bool get isOdd => _value.isOdd; | 476 | + bool get isOdd => value.isOdd; |
477 | 477 | ||
478 | /// Returns the minimum number of bits required to store this integer. | 478 | /// Returns the minimum number of bits required to store this integer. |
479 | /// | 479 | /// |
@@ -495,7 +495,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -495,7 +495,7 @@ class RxInt extends _BaseRxNum<int> { | ||
495 | /// (-3).bitLength == 2; // 11111101 | 495 | /// (-3).bitLength == 2; // 11111101 |
496 | /// (-4).bitLength == 2; // 11111100 | 496 | /// (-4).bitLength == 2; // 11111100 |
497 | /// ``` | 497 | /// ``` |
498 | - int get bitLength => _value.bitLength; | 498 | + int get bitLength => value.bitLength; |
499 | 499 | ||
500 | /// Returns the least significant [width] bits of this integer as a | 500 | /// Returns the least significant [width] bits of this integer as a |
501 | /// non-negative number (i.e. unsigned representation). The returned value | 501 | /// non-negative number (i.e. unsigned representation). The returned value |
@@ -517,7 +517,7 @@ class RxInt extends _BaseRxNum<int> { | @@ -517,7 +517,7 @@ class RxInt extends _BaseRxNum<int> { | ||
517 | /// ``` | 517 | /// ``` |
518 | /// x == x.toUnsigned(x.bitLength); | 518 | /// x == x.toUnsigned(x.bitLength); |
519 | /// ``` | 519 | /// ``` |
520 | - int toUnsigned(int width) => _value.toUnsigned(width); | 520 | + int toUnsigned(int width) => value.toUnsigned(width); |
521 | 521 | ||
522 | /// Returns the least significant [width] bits of this integer, extending the | 522 | /// Returns the least significant [width] bits of this integer, extending the |
523 | /// highest retained bit to the sign. This is the same as truncating the | 523 | /// highest retained bit to the sign. This is the same as truncating the |
@@ -547,46 +547,46 @@ class RxInt extends _BaseRxNum<int> { | @@ -547,46 +547,46 @@ class RxInt extends _BaseRxNum<int> { | ||
547 | /// ``` | 547 | /// ``` |
548 | /// x == x.toSigned(x.bitLength + 1); | 548 | /// x == x.toSigned(x.bitLength + 1); |
549 | /// ``` | 549 | /// ``` |
550 | - int toSigned(int width) => _value.toSigned(width); | 550 | + int toSigned(int width) => value.toSigned(width); |
551 | 551 | ||
552 | /// Return the negative value of this integer. | 552 | /// Return the negative value of this integer. |
553 | /// | 553 | /// |
554 | /// The result of negating an integer always has the opposite sign, except | 554 | /// The result of negating an integer always has the opposite sign, except |
555 | /// for zero, which is its own negation. | 555 | /// for zero, which is its own negation. |
556 | - int operator -() => -_value; | 556 | + int operator -() => -value; |
557 | 557 | ||
558 | /// Returns the absolute value of this integer. | 558 | /// Returns the absolute value of this integer. |
559 | /// | 559 | /// |
560 | /// For any integer `x`, the result is the same as `x < 0 ? -x : x`. | 560 | /// For any integer `x`, the result is the same as `x < 0 ? -x : x`. |
561 | - int abs() => _value.abs(); | 561 | + int abs() => value.abs(); |
562 | 562 | ||
563 | /// Returns the sign of this integer. | 563 | /// Returns the sign of this integer. |
564 | /// | 564 | /// |
565 | /// Returns 0 for zero, -1 for values less than zero and | 565 | /// Returns 0 for zero, -1 for values less than zero and |
566 | /// +1 for values greater than zero. | 566 | /// +1 for values greater than zero. |
567 | - int get sign => _value.sign; | 567 | + int get sign => value.sign; |
568 | 568 | ||
569 | /// Returns `this`. | 569 | /// Returns `this`. |
570 | - int round() => _value.round(); | 570 | + int round() => value.round(); |
571 | 571 | ||
572 | /// Returns `this`. | 572 | /// Returns `this`. |
573 | - int floor() => _value.floor(); | 573 | + int floor() => value.floor(); |
574 | 574 | ||
575 | /// Returns `this`. | 575 | /// Returns `this`. |
576 | - int ceil() => _value.ceil(); | 576 | + int ceil() => value.ceil(); |
577 | 577 | ||
578 | /// Returns `this`. | 578 | /// Returns `this`. |
579 | - int truncate() => _value.truncate(); | 579 | + int truncate() => value.truncate(); |
580 | 580 | ||
581 | /// Returns `this.toDouble()`. | 581 | /// Returns `this.toDouble()`. |
582 | - double roundToDouble() => _value.roundToDouble(); | 582 | + double roundToDouble() => value.roundToDouble(); |
583 | 583 | ||
584 | /// Returns `this.toDouble()`. | 584 | /// Returns `this.toDouble()`. |
585 | - double floorToDouble() => _value.floorToDouble(); | 585 | + double floorToDouble() => value.floorToDouble(); |
586 | 586 | ||
587 | /// Returns `this.toDouble()`. | 587 | /// Returns `this.toDouble()`. |
588 | - double ceilToDouble() => _value.ceilToDouble(); | 588 | + double ceilToDouble() => value.ceilToDouble(); |
589 | 589 | ||
590 | /// Returns `this.toDouble()`. | 590 | /// Returns `this.toDouble()`. |
591 | - double truncateToDouble() => _value.truncateToDouble(); | 591 | + double truncateToDouble() => value.truncateToDouble(); |
592 | } | 592 | } |
@@ -36,6 +36,10 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -36,6 +36,10 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
36 | 36 | ||
37 | void operator []=(int index, E val) { | 37 | void operator []=(int index, E val) { |
38 | _list[index] = val; | 38 | _list[index] = val; |
39 | + refresh(); | ||
40 | + } | ||
41 | + | ||
42 | + void refresh() { | ||
39 | subject.add(_list); | 43 | subject.add(_list); |
40 | } | 44 | } |
41 | 45 | ||
@@ -43,7 +47,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -43,7 +47,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
43 | /// inside the List, | 47 | /// inside the List, |
44 | RxList<E> operator +(Iterable<E> val) { | 48 | RxList<E> operator +(Iterable<E> val) { |
45 | addAll(val); | 49 | addAll(val); |
46 | - subject.add(_list); | 50 | + refresh(); |
47 | return this; | 51 | return this; |
48 | } | 52 | } |
49 | 53 | ||
@@ -53,13 +57,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -53,13 +57,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
53 | 57 | ||
54 | void add(E item) { | 58 | void add(E item) { |
55 | _list.add(item); | 59 | _list.add(item); |
56 | - subject.add(_list); | 60 | + refresh(); |
57 | } | 61 | } |
58 | 62 | ||
59 | @override | 63 | @override |
60 | void addAll(Iterable<E> item) { | 64 | void addAll(Iterable<E> item) { |
61 | _list.addAll(item); | 65 | _list.addAll(item); |
62 | - subject.add(_list); | 66 | + refresh(); |
63 | } | 67 | } |
64 | 68 | ||
65 | /// Add [item] to [List<E>] only if [item] is not null. | 69 | /// Add [item] to [List<E>] only if [item] is not null. |
@@ -87,13 +91,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -87,13 +91,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
87 | @override | 91 | @override |
88 | void insert(int index, E item) { | 92 | void insert(int index, E item) { |
89 | _list.insert(index, item); | 93 | _list.insert(index, item); |
90 | - subject.add(_list); | 94 | + refresh(); |
91 | } | 95 | } |
92 | 96 | ||
93 | @override | 97 | @override |
94 | void insertAll(int index, Iterable<E> iterable) { | 98 | void insertAll(int index, Iterable<E> iterable) { |
95 | _list.insertAll(index, iterable); | 99 | _list.insertAll(index, iterable); |
96 | - subject.add(_list); | 100 | + refresh(); |
97 | } | 101 | } |
98 | 102 | ||
99 | @override | 103 | @override |
@@ -108,7 +112,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -108,7 +112,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
108 | bool remove(Object item) { | 112 | bool remove(Object item) { |
109 | final hasRemoved = _list.remove(item); | 113 | final hasRemoved = _list.remove(item); |
110 | if (hasRemoved) { | 114 | if (hasRemoved) { |
111 | - subject.add(_list); | 115 | + refresh(); |
112 | } | 116 | } |
113 | return hasRemoved; | 117 | return hasRemoved; |
114 | } | 118 | } |
@@ -116,39 +120,39 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -116,39 +120,39 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
116 | @override | 120 | @override |
117 | E removeAt(int index) { | 121 | E removeAt(int index) { |
118 | final item = _list.removeAt(index); | 122 | final item = _list.removeAt(index); |
119 | - subject.add(_list); | 123 | + refresh(); |
120 | return item; | 124 | return item; |
121 | } | 125 | } |
122 | 126 | ||
123 | @override | 127 | @override |
124 | E removeLast() { | 128 | E removeLast() { |
125 | final item = _list.removeLast(); | 129 | final item = _list.removeLast(); |
126 | - subject.add(_list); | 130 | + refresh(); |
127 | return item; | 131 | return item; |
128 | } | 132 | } |
129 | 133 | ||
130 | @override | 134 | @override |
131 | void removeRange(int start, int end) { | 135 | void removeRange(int start, int end) { |
132 | _list.removeRange(start, end); | 136 | _list.removeRange(start, end); |
133 | - subject.add(_list); | 137 | + refresh(); |
134 | } | 138 | } |
135 | 139 | ||
136 | @override | 140 | @override |
137 | void removeWhere(bool Function(E) test) { | 141 | void removeWhere(bool Function(E) test) { |
138 | _list.removeWhere(test); | 142 | _list.removeWhere(test); |
139 | - subject.add(_list); | 143 | + refresh(); |
140 | } | 144 | } |
141 | 145 | ||
142 | @override | 146 | @override |
143 | void clear() { | 147 | void clear() { |
144 | _list.clear(); | 148 | _list.clear(); |
145 | - subject.add(_list); | 149 | + refresh(); |
146 | } | 150 | } |
147 | 151 | ||
148 | @override | 152 | @override |
149 | void sort([int compare(E a, E b)]) { | 153 | void sort([int compare(E a, E b)]) { |
150 | _list.sort(compare); | 154 | _list.sort(compare); |
151 | - subject.add(_list); | 155 | + refresh(); |
152 | } | 156 | } |
153 | 157 | ||
154 | @override | 158 | @override |
@@ -168,7 +172,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -168,7 +172,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
168 | 172 | ||
169 | void update(void fn(Iterable<E> value)) { | 173 | void update(void fn(Iterable<E> value)) { |
170 | fn(value); | 174 | fn(value); |
171 | - subject.add(_list); | 175 | + refresh(); |
172 | } | 176 | } |
173 | 177 | ||
174 | /// Replaces all existing items of this list with [items] | 178 | /// Replaces all existing items of this list with [items] |
@@ -197,7 +201,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -197,7 +201,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
197 | set value(List<E> val) { | 201 | set value(List<E> val) { |
198 | if (_list == val) return; | 202 | if (_list == val) return; |
199 | _list = val; | 203 | _list = val; |
200 | - subject.add(_list); | 204 | + refresh(); |
201 | } | 205 | } |
202 | 206 | ||
203 | Stream<List<E>> get stream => subject.stream; | 207 | Stream<List<E>> get stream => subject.stream; |
@@ -262,7 +266,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -262,7 +266,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
262 | @override | 266 | @override |
263 | void fillRange(int start, int end, [E fillValue]) { | 267 | void fillRange(int start, int end, [E fillValue]) { |
264 | _list.fillRange(start, end, fillValue); | 268 | _list.fillRange(start, end, fillValue); |
265 | - subject.add(_list); | 269 | + refresh(); |
266 | } | 270 | } |
267 | 271 | ||
268 | @override | 272 | @override |
@@ -323,7 +327,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -323,7 +327,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
323 | @override | 327 | @override |
324 | set length(int newLength) { | 328 | set length(int newLength) { |
325 | _list.length = newLength; | 329 | _list.length = newLength; |
326 | - subject.add(_list); | 330 | + refresh(); |
327 | } | 331 | } |
328 | 332 | ||
329 | @override | 333 | @override |
@@ -339,13 +343,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -339,13 +343,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
339 | @override | 343 | @override |
340 | void replaceRange(int start, int end, Iterable<E> replacement) { | 344 | void replaceRange(int start, int end, Iterable<E> replacement) { |
341 | _list.replaceRange(start, end, replacement); | 345 | _list.replaceRange(start, end, replacement); |
342 | - subject.add(_list); | 346 | + refresh(); |
343 | } | 347 | } |
344 | 348 | ||
345 | @override | 349 | @override |
346 | void retainWhere(bool Function(E) test) { | 350 | void retainWhere(bool Function(E) test) { |
347 | _list.retainWhere(test); | 351 | _list.retainWhere(test); |
348 | - subject.add(_list); | 352 | + refresh(); |
349 | } | 353 | } |
350 | 354 | ||
351 | @override | 355 | @override |
@@ -354,19 +358,19 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -354,19 +358,19 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
354 | @override | 358 | @override |
355 | void setAll(int index, Iterable<E> iterable) { | 359 | void setAll(int index, Iterable<E> iterable) { |
356 | _list.setAll(index, iterable); | 360 | _list.setAll(index, iterable); |
357 | - subject.add(_list); | 361 | + refresh(); |
358 | } | 362 | } |
359 | 363 | ||
360 | @override | 364 | @override |
361 | void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 365 | void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
362 | _list.setRange(start, end, iterable, skipCount); | 366 | _list.setRange(start, end, iterable, skipCount); |
363 | - subject.add(_list); | 367 | + refresh(); |
364 | } | 368 | } |
365 | 369 | ||
366 | @override | 370 | @override |
367 | void shuffle([Random random]) { | 371 | void shuffle([Random random]) { |
368 | _list.shuffle(random); | 372 | _list.shuffle(random); |
369 | - subject.add(_list); | 373 | + refresh(); |
370 | } | 374 | } |
371 | 375 | ||
372 | @override | 376 | @override |
@@ -425,13 +429,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -425,13 +429,13 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
425 | @override | 429 | @override |
426 | set first(E value) { | 430 | set first(E value) { |
427 | _list.first = value; | 431 | _list.first = value; |
428 | - subject.add(_list); | 432 | + refresh(); |
429 | } | 433 | } |
430 | 434 | ||
431 | @override | 435 | @override |
432 | set last(E value) { | 436 | set last(E value) { |
433 | _list.last = value; | 437 | _list.last = value; |
434 | - subject.add(_list); | 438 | + refresh(); |
435 | } | 439 | } |
436 | } | 440 | } |
437 | 441 |
@@ -26,6 +26,10 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | @@ -26,6 +26,10 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | ||
26 | return _value; | 26 | return _value; |
27 | } | 27 | } |
28 | 28 | ||
29 | + void refresh() { | ||
30 | + subject.add(_value); | ||
31 | + } | ||
32 | + | ||
29 | String get string => value.toString(); | 33 | String get string => value.toString(); |
30 | 34 | ||
31 | bool get canUpdate { | 35 | bool get canUpdate { |
@@ -54,7 +58,7 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | @@ -54,7 +58,7 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | ||
54 | set value(Map<K, V> val) { | 58 | set value(Map<K, V> val) { |
55 | if (_value == val) return; | 59 | if (_value == val) return; |
56 | _value = val; | 60 | _value = val; |
57 | - subject.add(_value); | 61 | + refresh(); |
58 | } | 62 | } |
59 | 63 | ||
60 | Stream<Map<K, V>> get stream => subject.stream; | 64 | Stream<Map<K, V>> get stream => subject.stream; |
@@ -73,14 +77,14 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | @@ -73,14 +77,14 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | ||
73 | 77 | ||
74 | void add(K key, V value) { | 78 | void add(K key, V value) { |
75 | _value[key] = value; | 79 | _value[key] = value; |
76 | - subject.add(_value); | 80 | + refresh(); |
77 | } | 81 | } |
78 | 82 | ||
79 | void addIf(dynamic condition, K key, V value) { | 83 | void addIf(dynamic condition, K key, V value) { |
80 | if (condition is Condition) condition = condition(); | 84 | if (condition is Condition) condition = condition(); |
81 | if (condition is bool && condition) { | 85 | if (condition is bool && condition) { |
82 | _value[key] = value; | 86 | _value[key] = value; |
83 | - subject.add(_value); | 87 | + refresh(); |
84 | } | 88 | } |
85 | } | 89 | } |
86 | 90 | ||
@@ -97,25 +101,25 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | @@ -97,25 +101,25 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | ||
97 | @override | 101 | @override |
98 | void operator []=(K key, V value) { | 102 | void operator []=(K key, V value) { |
99 | _value[key] = value; | 103 | _value[key] = value; |
100 | - subject.add(_value); | 104 | + refresh(); |
101 | } | 105 | } |
102 | 106 | ||
103 | @override | 107 | @override |
104 | void addAll(Map<K, V> other) { | 108 | void addAll(Map<K, V> other) { |
105 | _value.addAll(other); | 109 | _value.addAll(other); |
106 | - subject.add(_value); | 110 | + refresh(); |
107 | } | 111 | } |
108 | 112 | ||
109 | @override | 113 | @override |
110 | void addEntries(Iterable<MapEntry<K, V>> entries) { | 114 | void addEntries(Iterable<MapEntry<K, V>> entries) { |
111 | _value.addEntries(entries); | 115 | _value.addEntries(entries); |
112 | - subject.add(_value); | 116 | + refresh(); |
113 | } | 117 | } |
114 | 118 | ||
115 | @override | 119 | @override |
116 | void clear() { | 120 | void clear() { |
117 | _value.clear(); | 121 | _value.clear(); |
118 | - subject.add(_value); | 122 | + refresh(); |
119 | } | 123 | } |
120 | 124 | ||
121 | @override | 125 | @override |
@@ -154,21 +158,21 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | @@ -154,21 +158,21 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | ||
154 | @override | 158 | @override |
155 | V putIfAbsent(K key, V Function() ifAbsent) { | 159 | V putIfAbsent(K key, V Function() ifAbsent) { |
156 | final val = _value.putIfAbsent(key, ifAbsent); | 160 | final val = _value.putIfAbsent(key, ifAbsent); |
157 | - subject.add(_value); | 161 | + refresh(); |
158 | return val; | 162 | return val; |
159 | } | 163 | } |
160 | 164 | ||
161 | @override | 165 | @override |
162 | V remove(Object key) { | 166 | V remove(Object key) { |
163 | final val = _value.remove(key); | 167 | final val = _value.remove(key); |
164 | - subject.add(_value); | 168 | + refresh(); |
165 | return val; | 169 | return val; |
166 | } | 170 | } |
167 | 171 | ||
168 | @override | 172 | @override |
169 | void removeWhere(bool Function(K, V) test) { | 173 | void removeWhere(bool Function(K, V) test) { |
170 | _value.removeWhere(test); | 174 | _value.removeWhere(test); |
171 | - subject.add(_value); | 175 | + refresh(); |
172 | } | 176 | } |
173 | 177 | ||
174 | @override | 178 | @override |
@@ -180,14 +184,14 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | @@ -180,14 +184,14 @@ class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { | ||
180 | @override | 184 | @override |
181 | V update(K key, V Function(V) update, {V Function() ifAbsent}) { | 185 | V update(K key, V Function(V) update, {V Function() ifAbsent}) { |
182 | final val = _value.update(key, update, ifAbsent: ifAbsent); | 186 | final val = _value.update(key, update, ifAbsent: ifAbsent); |
183 | - subject.add(_value); | 187 | + refresh(); |
184 | return val; | 188 | return val; |
185 | } | 189 | } |
186 | 190 | ||
187 | @override | 191 | @override |
188 | void updateAll(V Function(K, V) update) { | 192 | void updateAll(V Function(K, V) update) { |
189 | _value.updateAll(update); | 193 | _value.updateAll(update); |
190 | - subject.add(_value); | 194 | + refresh(); |
191 | } | 195 | } |
192 | } | 196 | } |
193 | 197 |
@@ -42,25 +42,29 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -42,25 +42,29 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
42 | if (condition is bool && condition) addAll(items); | 42 | if (condition is bool && condition) addAll(items); |
43 | } | 43 | } |
44 | 44 | ||
45 | + void refresh() { | ||
46 | + subject.add(_set); | ||
47 | + } | ||
48 | + | ||
45 | /// Special override to push() element(s) in a reactive way | 49 | /// Special override to push() element(s) in a reactive way |
46 | /// inside the List, | 50 | /// inside the List, |
47 | RxSet<E> operator +(Set<E> val) { | 51 | RxSet<E> operator +(Set<E> val) { |
48 | addAll(val); | 52 | addAll(val); |
49 | - subject.add(_set); | 53 | + refresh(); |
50 | return this; | 54 | return this; |
51 | } | 55 | } |
52 | 56 | ||
53 | @override | 57 | @override |
54 | bool add(E value) { | 58 | bool add(E value) { |
55 | final val = _set.add(value); | 59 | final val = _set.add(value); |
56 | - subject.add(_set); | 60 | + refresh(); |
57 | return val; | 61 | return val; |
58 | } | 62 | } |
59 | 63 | ||
60 | @override | 64 | @override |
61 | void addAll(Iterable<E> item) { | 65 | void addAll(Iterable<E> item) { |
62 | _set.addAll(item); | 66 | _set.addAll(item); |
63 | - subject.add(_set); | 67 | + refresh(); |
64 | } | 68 | } |
65 | 69 | ||
66 | /// Adds only if [item] is not null. | 70 | /// Adds only if [item] is not null. |
@@ -83,19 +87,19 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -83,19 +87,19 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
83 | bool remove(Object item) { | 87 | bool remove(Object item) { |
84 | var hasRemoved = _set.remove(item); | 88 | var hasRemoved = _set.remove(item); |
85 | if (hasRemoved) { | 89 | if (hasRemoved) { |
86 | - subject.add(_set); | 90 | + refresh(); |
87 | } | 91 | } |
88 | return hasRemoved; | 92 | return hasRemoved; |
89 | } | 93 | } |
90 | 94 | ||
91 | void removeWhere(bool Function(E) test) { | 95 | void removeWhere(bool Function(E) test) { |
92 | _set.removeWhere(test); | 96 | _set.removeWhere(test); |
93 | - subject.add(_set); | 97 | + refresh(); |
94 | } | 98 | } |
95 | 99 | ||
96 | void clear() { | 100 | void clear() { |
97 | _set.clear(); | 101 | _set.clear(); |
98 | - subject.add(_set); | 102 | + refresh(); |
99 | } | 103 | } |
100 | 104 | ||
101 | void close() { | 105 | void close() { |
@@ -114,7 +118,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -114,7 +118,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
114 | 118 | ||
115 | void update(void fn(Iterable<E> value)) { | 119 | void update(void fn(Iterable<E> value)) { |
116 | fn(value); | 120 | fn(value); |
117 | - subject.add(_set); | 121 | + refresh(); |
118 | } | 122 | } |
119 | 123 | ||
120 | /// Replaces all existing items of this list with [items] | 124 | /// Replaces all existing items of this list with [items] |
@@ -145,7 +149,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -145,7 +149,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
145 | set value(Set<E> val) { | 149 | set value(Set<E> val) { |
146 | if (_set == val) return; | 150 | if (_set == val) return; |
147 | _set = val; | 151 | _set = val; |
148 | - subject.add(_set); | 152 | + refresh(); |
149 | } | 153 | } |
150 | 154 | ||
151 | Stream<Set<E>> get stream => subject.stream; | 155 | Stream<Set<E>> get stream => subject.stream; |
@@ -309,19 +313,19 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -309,19 +313,19 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
309 | @override | 313 | @override |
310 | void removeAll(Iterable<Object> elements) { | 314 | void removeAll(Iterable<Object> elements) { |
311 | _set.removeAll(elements); | 315 | _set.removeAll(elements); |
312 | - subject.add(_set); | 316 | + refresh(); |
313 | } | 317 | } |
314 | 318 | ||
315 | @override | 319 | @override |
316 | void retainAll(Iterable<Object> elements) { | 320 | void retainAll(Iterable<Object> elements) { |
317 | _set.retainAll(elements); | 321 | _set.retainAll(elements); |
318 | - subject.add(_set); | 322 | + refresh(); |
319 | } | 323 | } |
320 | 324 | ||
321 | @override | 325 | @override |
322 | void retainWhere(bool Function(E) E) { | 326 | void retainWhere(bool Function(E) E) { |
323 | _set.retainWhere(E); | 327 | _set.retainWhere(E); |
324 | - subject.add(_set); | 328 | + refresh(); |
325 | } | 329 | } |
326 | 330 | ||
327 | @override | 331 | @override |
-
Please register or login to post a comment