Showing
3 changed files
with
13 additions
and
8 deletions
| @@ -13,12 +13,6 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -13,12 +13,6 @@ class _RxImpl<T> implements RxInterface<T> { | ||
| 13 | HashMap<Stream<T>, StreamSubscription>(); | 13 | HashMap<Stream<T>, StreamSubscription>(); |
| 14 | 14 | ||
| 15 | T _value; | 15 | T _value; |
| 16 | - T get value { | ||
| 17 | - if (getObs != null) { | ||
| 18 | - getObs.addListener(subject.stream); | ||
| 19 | - } | ||
| 20 | - return _value; | ||
| 21 | - } | ||
| 22 | 16 | ||
| 23 | /// Common to all Types [T], this operator overloading is using for | 17 | /// Common to all Types [T], this operator overloading is using for |
| 24 | /// assignment, same as rx.value | 18 | /// assignment, same as rx.value |
| @@ -143,6 +137,13 @@ class _RxImpl<T> implements RxInterface<T> { | @@ -143,6 +137,13 @@ class _RxImpl<T> implements RxInterface<T> { | ||
| 143 | subject.add(_value); | 137 | subject.add(_value); |
| 144 | } | 138 | } |
| 145 | 139 | ||
| 140 | + T get value { | ||
| 141 | + if (getObs != null) { | ||
| 142 | + getObs.addListener(subject.stream); | ||
| 143 | + } | ||
| 144 | + return _value; | ||
| 145 | + } | ||
| 146 | + | ||
| 146 | Stream<T> get stream => subject.stream; | 147 | Stream<T> get stream => subject.stream; |
| 147 | 148 | ||
| 148 | StreamSubscription<T> listen(void Function(T) onData, | 149 | StreamSubscription<T> listen(void Function(T) onData, |
| @@ -17,6 +17,10 @@ abstract class RxInterface<T> { | @@ -17,6 +17,10 @@ abstract class RxInterface<T> { | ||
| 17 | 17 | ||
| 18 | bool get canUpdate; | 18 | bool get canUpdate; |
| 19 | 19 | ||
| 20 | + set value(T val); | ||
| 21 | + | ||
| 22 | + T get value; | ||
| 23 | + | ||
| 20 | /// Closes the stream | 24 | /// Closes the stream |
| 21 | void close() => subject?.close(); | 25 | void close() => subject?.close(); |
| 22 | 26 | ||
| @@ -75,7 +79,7 @@ abstract class DisposableInterface { | @@ -75,7 +79,7 @@ abstract class DisposableInterface { | ||
| 75 | /// Or dispose objects that can potentially create some memory leaks, | 79 | /// Or dispose objects that can potentially create some memory leaks, |
| 76 | /// like TextEditingControllers, AnimationControllers. | 80 | /// like TextEditingControllers, AnimationControllers. |
| 77 | /// Might be useful as well to persist some data on disk. | 81 | /// Might be useful as well to persist some data on disk. |
| 78 | - void onClose() async {} | 82 | + Future<void> onClose() async {} |
| 79 | } | 83 | } |
| 80 | 84 | ||
| 81 | /// Used like [SingleTickerProviderMixin] but only with Get Controllers. | 85 | /// Used like [SingleTickerProviderMixin] but only with Get Controllers. |
| @@ -48,7 +48,7 @@ class GetxController extends DisposableInterface { | @@ -48,7 +48,7 @@ class GetxController extends DisposableInterface { | ||
| 48 | void onReady() async {} | 48 | void onReady() async {} |
| 49 | 49 | ||
| 50 | @override | 50 | @override |
| 51 | - void onClose() async {} | 51 | + Future<void> onClose() async {} |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | class GetBuilder<T extends GetxController> extends StatefulWidget { | 54 | class GetBuilder<T extends GetxController> extends StatefulWidget { |
-
Please register or login to post a comment