Jonny Borges
Committed by GitHub

bump to 2.7.1

  1 +## [2.7.1]
  2 +- Improve list to set and get methods
  3 +
1 ## [2.7.0] 4 ## [2.7.0]
2 - Added obx, a simple state interceptor. 5 - Added obx, a simple state interceptor.
3 - Improve Bindings, ListX, and fix docs typos 6 - Improve Bindings, ListX, and fix docs typos

40.4 KB | W: | H:

23.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
@@ -11,14 +11,17 @@ class _StoredValue<T> implements RxInterface<T> { @@ -11,14 +11,17 @@ class _StoredValue<T> implements RxInterface<T> {
11 Map<Stream<Change<T>>, StreamSubscription> _subscriptions = Map(); 11 Map<Stream<Change<T>>, StreamSubscription> _subscriptions = Map();
12 12
13 T _value; 13 T _value;
14 - T get value { 14 + T get v {
15 if (Get.obs != null) { 15 if (Get.obs != null) {
16 Get.obs.addListener(subject.stream); 16 Get.obs.addListener(subject.stream);
17 } 17 }
18 return _value; 18 return _value;
19 } 19 }
20 20
21 - String get string => value.toString(); 21 + T get value => v;
  22 + set value(T va) => v = va;
  23 +
  24 + String get string => v.toString();
22 25
23 close() { 26 close() {
24 _subscriptions.forEach((observable, subscription) { 27 _subscriptions.forEach((observable, subscription) {
@@ -38,7 +41,7 @@ class _StoredValue<T> implements RxInterface<T> { @@ -38,7 +41,7 @@ class _StoredValue<T> implements RxInterface<T> {
38 }); 41 });
39 } 42 }
40 43
41 - set value(T val) { 44 + set v(T val) {
42 if (_value == val) return; 45 if (_value == val) return;
43 T old = _value; 46 T old = _value;
44 _value = val; 47 _value = val;
@@ -51,14 +54,14 @@ class _StoredValue<T> implements RxInterface<T> { @@ -51,14 +54,14 @@ class _StoredValue<T> implements RxInterface<T> {
51 _onChange = subject.stream.asBroadcastStream(); 54 _onChange = subject.stream.asBroadcastStream();
52 } 55 }
53 56
54 - void setCast(dynamic /* T */ val) => value = val; 57 + void setCast(dynamic /* T */ val) => v = val;
55 58
56 Stream<Change<T>> _onChange; 59 Stream<Change<T>> _onChange;
57 60
58 Stream<Change<T>> get onChange { 61 Stream<Change<T>> get onChange {
59 _cb++; 62 _cb++;
60 63
61 - _changeCtl.add(Change<T>($new: value, $old: null, batch: _cb)); 64 + _changeCtl.add(Change<T>($new: v, $old: null, batch: _cb));
62 _changeCtl.addStream(_onChange.skipWhile((v) => v.batch < _cb)); 65 _changeCtl.addStream(_onChange.skipWhile((v) => v.batch < _cb));
63 return _changeCtl.stream.asBroadcastStream(); 66 return _changeCtl.stream.asBroadcastStream();
64 } 67 }
@@ -66,11 +69,11 @@ class _StoredValue<T> implements RxInterface<T> { @@ -66,11 +69,11 @@ class _StoredValue<T> implements RxInterface<T> {
66 Stream<T> get stream => onChange.map((c) => c.$new); 69 Stream<T> get stream => onChange.map((c) => c.$new);
67 70
68 void bind(RxInterface<T> reactive) { 71 void bind(RxInterface<T> reactive) {
69 - value = reactive.value;  
70 - reactive.stream.listen((v) => value = v); 72 + v = reactive.v;
  73 + reactive.stream.listen((va) => v = va);
71 } 74 }
72 75
73 - void bindStream(Stream<T> stream) => stream.listen((v) => value = v); 76 + void bindStream(Stream<T> stream) => stream.listen((va) => v = va);
74 77
75 void bindOrSet(/* T | Stream<T> | Reactive<T> */ other) { 78 void bindOrSet(/* T | Stream<T> | Reactive<T> */ other) {
76 if (other is RxInterface<T>) { 79 if (other is RxInterface<T>) {
@@ -78,7 +81,7 @@ class _StoredValue<T> implements RxInterface<T> { @@ -78,7 +81,7 @@ class _StoredValue<T> implements RxInterface<T> {
78 } else if (other is Stream<T>) { 81 } else if (other is Stream<T>) {
79 bindStream(other.cast<T>()); 82 bindStream(other.cast<T>());
80 } else { 83 } else {
81 - value = other; 84 + v = other;
82 } 85 }
83 } 86 }
84 87
@@ -245,22 +248,19 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> { @@ -245,22 +248,19 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> {
245 }); 248 });
246 } 249 }
247 250
248 - // @override  
249 - // int get length => list.length;  
250 -  
251 - // List<E> get list => value as List<E>; 251 + List<E> get value => v as List<E>;
252 252
253 - // set list(List<E> v) => assignAll(v); 253 + set value(List<E> va) => assignAll(va);
254 254
255 @override 255 @override
256 - get value { 256 + get v {
257 if (Get.obs != null) { 257 if (Get.obs != null) {
258 Get.obs.addListener(subject.stream); 258 Get.obs.addListener(subject.stream);
259 } 259 }
260 return this; 260 return this;
261 } 261 }
262 262
263 - set value(E val) { 263 + set v(E val) {
264 assign(val); 264 assign(val);
265 } 265 }
266 266
@@ -269,11 +269,11 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> { @@ -269,11 +269,11 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> {
269 269
270 @override 270 @override
271 void bind(RxInterface<E> reactive) { 271 void bind(RxInterface<E> reactive) {
272 - value = reactive.value;  
273 - reactive.stream.listen((v) => value = v); 272 + v = reactive.v;
  273 + reactive.stream.listen((va) => v = va);
274 } 274 }
275 275
276 - void bindStream(Stream<E> stream) => stream.listen((v) => value = v); 276 + void bindStream(Stream<E> stream) => stream.listen((va) => v = va);
277 277
278 @override 278 @override
279 void bindOrSet(/* T | Stream<T> or Rx<T> */ other) { 279 void bindOrSet(/* T | Stream<T> or Rx<T> */ other) {
@@ -282,7 +282,7 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> { @@ -282,7 +282,7 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> {
282 } else if (other is Stream<E>) { 282 } else if (other is Stream<E>) {
283 bindStream(other.cast<E>()); 283 bindStream(other.cast<E>());
284 } else { 284 } else {
285 - value = other; 285 + v = other;
286 } 286 }
287 } 287 }
288 288
@@ -291,7 +291,7 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> { @@ -291,7 +291,7 @@ class ListX<E> extends DelegatingList<E> implements List<E>, RxInterface<E> {
291 stream.listen(callback); 291 stream.listen(callback);
292 292
293 @override 293 @override
294 - void setCast(dynamic val) => value = val; 294 + void setCast(dynamic val) => v = val;
295 } 295 }
296 296
297 typedef bool Condition(); 297 typedef bool Condition();
@@ -6,10 +6,10 @@ abstract class RxInterface<T> { @@ -6,10 +6,10 @@ abstract class RxInterface<T> {
6 RxInterface([T initial]); 6 RxInterface([T initial]);
7 7
8 /// Get current value 8 /// Get current value
9 - get value; 9 + get v;
10 10
11 /// Set value 11 /// Set value
12 - set value(T val); 12 + set v(T val);
13 13
14 /// Cast [val] to [T] before setting 14 /// Cast [val] to [T] before setting
15 void setCast(dynamic /* T */ val); 15 void setCast(dynamic /* T */ val);
1 name: get 1 name: get
2 description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. 2 description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
3 -version: 2.7.0 3 +version: 2.7.1
4 homepage: https://github.com/jonataslaw/get 4 homepage: https://github.com/jonataslaw/get
5 5
6 environment: 6 environment: