RxState<T> class
RxState 是响应式状态的基础单元。
它封装了一个类型为 T 的值,并提供了自动依赖追踪和字段级(Map/List)更新机制
- Implementers
- Available extensions
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → dynamic
-
唯一标识符,用于调试或在 listenWithId 中识别来源。
final
- isEmpty → bool
-
Available on RxState<
判断是否为空List< , provided by the RxListToState extensionT> >no setter - isNotEmpty → bool
-
Available on RxState<
判断是否不为空List< , provided by the RxListToState extensionT> >no setter - length → int
-
Available on RxState<
获取列表长度List< , provided by the RxListToState extensionT> >no setter - name → String?
-
友好的名称,主要用于日志打印。
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T
-
获取当前值,并自动触发 RxStack 的依赖收集。
getter/setter pair
Methods
-
add(
T element) → void -
Available on RxState<
向列表添加元素,并刷新 UIList< , provided by the RxListToState extensionT> > -
addFieldListener(
dynamic field, void listener(dynamic)) → void -
addInternalListener(
void listener(dynamic)) → void -
addListener(
void listener(dynamic)) → void -
addListenerWithId(
void listener(dynamic)) → void -
bind(
void onUpdate(T value)) → void Function() - 绑定一个监听器。
-
contains(
T element) → bool -
Available on RxState<
判断是否包含元素List< , provided by the RxListToState extensionT> > -
dec(
) → void -
Available on RxState<
自减int> , provided by the RxIntOps extension -
deepEquals(
dynamic a, dynamic b) → bool -
dispose(
) → void - 销毁状态,清空所有监听器。
-
getItem(
dynamic field) → dynamic - 获取集合中的特定字段或索引。
-
inc(
) → void -
Available on RxState<
自增int> , provided by the RxIntOps extension -
internalUpdate(
T newValue) → void -
listen(
void onData(T value)) → void Function() -
监听值变化,并立即执行一次
onData。 -
listenByKey(
dynamic key, void onData(dynamic value)) → void Function() - 监听特定字段的变化。
-
listenWhere(
bool test(dynamic item), void onData(dynamic item)) → void Function() -
listenWithId(
void onData(T value, dynamic id)) → void Function() -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyFieldListeners(
dynamic field, bool notifyGlobal) → void -
refresh(
) → void - 手动触发通知。
-
remove(
T element) → void -
Available on RxState<
从列表移除元素,并刷新 UIList< , provided by the RxListToState extensionT> > -
removeFieldListener(
dynamic field, void listener(dynamic)) → void -
removeListener(
void listener(dynamic)) → void -
runAsync(
Future< T> task(), {RxState<bool> ? loadingState, int retryCount = 3, Duration retryDelay = const Duration(seconds: 2)}) → Future<void> -
Available on RxState<
执行异步任务并自动更新状态T> , provided by the RxAsyncExtension extension -
toString(
) → String -
A string representation of this object.
inherited
-
trackFieldAccess(
dynamic field) → void -
update(
dynamic newValue) → void - 更新整个状态或尝试类型转换更新。
-
updateField<
K extends Object> (K field, Object? newValue, {bool notifyGlobal = false}) → void - 更新 Map 的特定 Key 或 List 的特定 Index。
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited