FrUnionViewModel class
提供一个全局VM, 用于简化代码. ⚠️ 单一全局VM不适用于复杂应用场景, 跨app复用状态可能造成不可预知的错误 与M对应的VM方法,请考虑通过 extension 封装
Constructors
-
FrUnionViewModel(Set<
FrUnionModel> models) -
factory
- FrUnionViewModel.build(FrUnion initValue)
-
FrUnionViewModel.ofTag(Set<
TaggedUnionModel> tagModels) -
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- initValue → FrUnion
-
when
_subjectinit, get seed valuefinal - logExtra → LogExtra?
-
set put log type
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
↔ ValueStream<
FrUnion> -
subject.streamgetter/setter pairinherited -
subject
→ BehaviorSubject<
FrUnion> -
no setterinherited
- value → FrUnion
-
subject.valueno setterinherited
Methods
-
autoDispose<
T extends StreamSubscription?> (T subs, {String? tag}) → T -
inherited
-
autoDisposeNotifier<
N extends ChangeNotifier?> (N ntf, {String? tag}) → N -
inherited
-
debounce<
R> (Object tag, Duration duration, FutureOr< R> action(), {Duration? maxDuration}) → FutureOr<R?> -
debounce 防抖: 停止操作后等待
duration执行最后一次。maxDuration: 可选,解决“无限重置”问题。如果持续触发超过此时间,强制执行一次。inherited -
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
dispose(
) → void -
inherited
-
frPrint(
String message, {DateTime? time, int? sequenceNumber, int? level, String? name, Zone? zone, Object? error, StackTrace? stackTrace}) → dynamic -
inherited
-
isDebounceLocked(
Object tag) → bool -
检查是否正在防抖等待中
inherited
-
isMutexLocked(
Object tag) → bool -
检查是否正在执行 mutex 任务
inherited
-
isThrottleLocked(
Object tag) → bool -
检查是否处于节流冷却期
inherited
-
logF(
String message, {LogExtra? logExtra, Object? error, StackTrace? stackTrace, DateTime? time, int? sequenceNumber, String? name, Zone? zone}) → void -
inherited
-
logger(
String message, {LogExtra? logExtra, DateTime? time, int? sequenceNumber, int level = 800, String? name, Zone? zone, Object? error, StackTrace? stackTrace, bool uriFrame = true}) → dynamic -
logExtraprint stack frame infonamelogger.name null: will use 'runtimeType'stackTracewill print with red color by dev.log but iferror== null: will ignorestackTraceinherited -
logI(
String message, {LogExtra? logExtra, Object? error, StackTrace? stackTrace, DateTime? time, int? sequenceNumber, String? name, Zone? zone}) → void -
inherited
-
logS(
String message, {LogExtra? logExtra, Object? error, StackTrace? stackTrace, DateTime? time, int? sequenceNumber, String? name, Zone? zone}) → void -
for debug 'shout'
inherited
-
mutex<
R> (Object tag, FutureOr< R> action()) → FutureOr<R?> -
mutex 互斥锁 (Exhaust): 立即执行,执行期间的触发直接丢弃。
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
ntfBy<
T extends ChangeNotifier> (String tag) → T -
inherited
-
put(
FrUnion value) → FrUnion -
put value to
_subjectinherited -
putError(
Object error, [StackTrace? stackTrace]) → void -
put error value to
_subjectinherited -
putWithLogging(
FrUnion value, {OnLogging< FrUnion> ? logging}) → FrUnion -
inherited
-
runCatching<
R> (FutureOr< R?> block(), {FutureOr<R?> onSuccess(R data)?, FutureOr<R?> onFailure(Object e, StackTrace s)?, bool ignoreSkipError = true, int slowlyMs = 0, Object? debounceTag, Object? throttleTag, Object? mutexTag}) → FutureOr<R?> -
run and catch error, then putError
inherited
-
skpIf(
bool condition, String reason, {Level level = Level.FINE}) → void -
if you want interrupt the normal flow, but not trigger
runCatching.onFailureinherited -
skpIfNull(
Object? obj, String reason) → void -
if
obj==null, throw SkipError ref skpIfinherited -
skpNull<
T> (T? obj, String reason, {Level level = Level.FINE}) → T -
if
obj== null: throw SkipError else: returnobj!inherited -
streamBy<
M> ({String tag = ''}) → ValueStream< M> -
subBy<
T extends StreamSubscription> (String tag) → T -
inherited
-
throttle<
R> (Object tag, Duration duration, FutureOr< R> action(), {bool ensureLast = false}) → FutureOr<R?> -
throttle 节流: 固定频率执行。
配合 mutex 解决异步任务重叠问题:如果周期到了但上次任务还没跑完,直接跳过。
ensureLast: 如果为 true,则在节流期间的最后一次触发将被防抖补发。inherited -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
-
update(
FutureOr< FrUnion> updater(FrUnion old), {dynamic onError(Object e, StackTrace s)?, int slowlyMs = 100, Object? debounceTag, Object? throttleTag, Object? mutexTag, dynamic ignoreSkipError = true, String onPutLogging(FrUnion cur)?, OnLogging<FrUnion> ? logging}) → FutureOr<FrUnion?> -
updaterif return value, will callputif return null, will not callput/putErroronErrorif set null,will callputErrorif set function value, will not callputError, you can invokeputErrormanuallyslowlyMsif set <=0 value, will ignore debounce/throttleTagdebounceTagenable debounce, require unique within the VM scopethrottleTagenable throttle, require unique within the VM scopemutexTagenable concurrency lock (Exhaustive behavior), if the previous update with the same mutexTag is still running, the current update will be ignored.ignoreSkipErrorrefrunCatching.ignoreSkipErrorinherited -
updateBy<
M> (FutureOr< M> updater(M old), {String tag = '', dynamic onError(Object e, StackTrace s)?, int slowlyMs = 100, Object? debounceTag, Object? throttleTag, Object? mutexTag, OnLogging<M> ? logging}) → FutureOr<M?> -
updateRaw(
FutureOr< FrUnion> up(FrUnion old), {dynamic onError(Object e, StackTrace s)?, int slowlyMs = 100, Object? debounceTag, Object? throttleTag, dynamic ignoreSkipError = true}) → FutureOr<FrUnion?> -
Deprecated use 'update'
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited