Committed by
GitHub
Merge pull request #2096 from jonataslaw/sm-refactor
Sm refactor
Showing
9 changed files
with
12 additions
and
17 deletions
| @@ -34,8 +34,8 @@ class RxSet<E> extends GetListenable<Set<E>> | @@ -34,8 +34,8 @@ class RxSet<E> extends GetListenable<Set<E>> | ||
| 34 | } | 34 | } | 
| 35 | 35 | ||
| 36 | @override | 36 | @override | 
| 37 | - bool add(E value) { | ||
| 38 | - final hasAdded = value.add(value); | 37 | + bool add(E val) { | 
| 38 | + final hasAdded = value.add(val); | ||
| 39 | if (hasAdded) { | 39 | if (hasAdded) { | 
| 40 | refresh(); | 40 | refresh(); | 
| 41 | } | 41 | } | 
| @@ -5,13 +5,10 @@ import '../../../get_core/get_core.dart'; | @@ -5,13 +5,10 @@ import '../../../get_core/get_core.dart'; | ||
| 5 | import '../../../get_instance/src/get_instance.dart'; | 5 | import '../../../get_instance/src/get_instance.dart'; | 
| 6 | import '../../../get_instance/src/lifecycle.dart'; | 6 | import '../../../get_instance/src/lifecycle.dart'; | 
| 7 | import '../simple/list_notifier.dart'; | 7 | import '../simple/list_notifier.dart'; | 
| 8 | -import '../simple/simple_builder.dart'; | ||
| 9 | 8 | ||
| 10 | typedef GetXControllerBuilder<T extends GetLifeCycleMixin> = Widget Function( | 9 | typedef GetXControllerBuilder<T extends GetLifeCycleMixin> = Widget Function( | 
| 11 | T controller); | 10 | T controller); | 
| 12 | 11 | ||
| 13 | -class StatefulObserverComponent = StatefulElement with ObserverComponent; | ||
| 14 | - | ||
| 15 | class GetX<T extends GetLifeCycleMixin> extends StatefulWidget { | 12 | class GetX<T extends GetLifeCycleMixin> extends StatefulWidget { | 
| 16 | final GetXControllerBuilder<T> builder; | 13 | final GetXControllerBuilder<T> builder; | 
| 17 | final bool global; | 14 | final bool global; | 
| @@ -128,7 +125,7 @@ class GetXState<T extends GetLifeCycleMixin> extends State<GetX<T>> { | @@ -128,7 +125,7 @@ class GetXState<T extends GetLifeCycleMixin> extends State<GetX<T>> { | ||
| 128 | final disposers = <Disposer>[]; | 125 | final disposers = <Disposer>[]; | 
| 129 | 126 | ||
| 130 | @override | 127 | @override | 
| 131 | - Widget build(BuildContext context) => TaskManager.instance | 128 | + Widget build(BuildContext context) => NotifierManager.instance | 
| 132 | .exchange(disposers, _update, () => widget.builder(controller!)); | 129 | .exchange(disposers, _update, () => widget.builder(controller!)); | 
| 133 | 130 | ||
| 134 | @override | 131 | @override | 
| @@ -361,7 +361,6 @@ class BindWrapper<T> extends InheritedWidget { | @@ -361,7 +361,6 @@ class BindWrapper<T> extends InheritedWidget { | ||
| 361 | this.didUpdateWidget, | 361 | this.didUpdateWidget, | 
| 362 | }) : super(key: key, child: child); | 362 | }) : super(key: key, child: child); | 
| 363 | 363 | ||
| 364 | - | ||
| 365 | final InitBuilder<T>? init; | 364 | final InitBuilder<T>? init; | 
| 366 | final bool global; | 365 | final bool global; | 
| 367 | final Object? id; | 366 | final Object? id; | 
| @@ -44,12 +44,12 @@ mixin ListNotifierSingleMixin on Listenable { | @@ -44,12 +44,12 @@ mixin ListNotifierSingleMixin on Listenable { | ||
| 44 | 44 | ||
| 45 | @protected | 45 | @protected | 
| 46 | void reportRead() { | 46 | void reportRead() { | 
| 47 | - TaskManager.instance.notify(this); | 47 | + NotifierManager.instance.notify(this); | 
| 48 | } | 48 | } | 
| 49 | 49 | ||
| 50 | @protected | 50 | @protected | 
| 51 | void reportAdd(VoidCallback disposer) { | 51 | void reportAdd(VoidCallback disposer) { | 
| 52 | - TaskManager.instance.reportAdd(disposer); | 52 | + NotifierManager.instance.reportAdd(disposer); | 
| 53 | } | 53 | } | 
| 54 | 54 | ||
| 55 | void _notifyUpdate() { | 55 | void _notifyUpdate() { | 
| @@ -96,7 +96,7 @@ mixin ListNotifierGroupMixin on Listenable { | @@ -96,7 +96,7 @@ mixin ListNotifierGroupMixin on Listenable { | ||
| 96 | @protected | 96 | @protected | 
| 97 | void notifyGroupChildrens(Object id) { | 97 | void notifyGroupChildrens(Object id) { | 
| 98 | assert(_debugAssertNotDisposed()); | 98 | assert(_debugAssertNotDisposed()); | 
| 99 | - TaskManager.instance.notify(_updatersGroupIds![id]!); | 99 | + NotifierManager.instance.notify(_updatersGroupIds![id]!); | 
| 100 | } | 100 | } | 
| 101 | 101 | ||
| 102 | bool containsId(Object id) { | 102 | bool containsId(Object id) { | 
| @@ -148,12 +148,12 @@ mixin ListNotifierGroupMixin on Listenable { | @@ -148,12 +148,12 @@ mixin ListNotifierGroupMixin on Listenable { | ||
| 148 | } | 148 | } | 
| 149 | } | 149 | } | 
| 150 | 150 | ||
| 151 | -class TaskManager { | ||
| 152 | - TaskManager._(); | 151 | +class NotifierManager { | 
| 152 | + NotifierManager._(); | ||
| 153 | 153 | ||
| 154 | - static TaskManager? _instance; | 154 | + static NotifierManager? _instance; | 
| 155 | 155 | ||
| 156 | - static TaskManager get instance => _instance ??= TaskManager._(); | 156 | + static NotifierManager get instance => _instance ??= NotifierManager._(); | 
| 157 | 157 | ||
| 158 | GetStateUpdate? _setter; | 158 | GetStateUpdate? _setter; | 
| 159 | List<VoidCallback>? _remove; | 159 | List<VoidCallback>? _remove; | 
| @@ -176,9 +176,7 @@ class TaskManager { | @@ -176,9 +176,7 @@ class TaskManager { | ||
| 176 | T Function() builder) { | 176 | T Function() builder) { | 
| 177 | _remove = disposers; | 177 | _remove = disposers; | 
| 178 | _setter = setState; | 178 | _setter = setState; | 
| 179 | - | ||
| 180 | final result = builder(); | 179 | final result = builder(); | 
| 181 | - print(disposers.isEmpty); | ||
| 182 | if (disposers.isEmpty) { | 180 | if (disposers.isEmpty) { | 
| 183 | throw ObxError(); | 181 | throw ObxError(); | 
| 184 | } | 182 | } | 
| @@ -101,7 +101,7 @@ mixin ObserverComponent on ComponentElement { | @@ -101,7 +101,7 @@ mixin ObserverComponent on ComponentElement { | ||
| 101 | 101 | ||
| 102 | @override | 102 | @override | 
| 103 | Widget build() => | 103 | Widget build() => | 
| 104 | - TaskManager.instance.exchange(disposers, markNeedsBuild, super.build); | 104 | + NotifierManager.instance.exchange(disposers, markNeedsBuild, super.build); | 
| 105 | 105 | ||
| 106 | @override | 106 | @override | 
| 107 | void unmount() { | 107 | void unmount() { | 
- 
Please register or login to post a comment