LxVar<T> class

A reactive variable that holds a mutable value.

LxVar is the primary way to define piece of mutable state in the Levit ecosystem. It extends LxBase to provide a public setter for value and additional fluent utilities.

Usage

final count = LxVar(0);
count.value++; // Updates and notifies
Inheritance
Available extensions

Constructors

LxVar(T initial, {void onListen()?, void onCancel()?, String? name})
Creates a reactive variable with an initial value.

Properties

computedValue → T

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Alias for requireValue.
no setter
errorOrNull Object?

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns the current error if the status is LxError, otherwise null.
no setter
graphDepth int
Returns the current depth in the dependency graph.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
hasListener bool
Whether there are active listeners.
no setterinherited
hasValue bool

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Alias for isSuccess.
no setter
id int
A unique runtime identifier for this reactive instance.
finalinherited
isDisposed bool
Whether the reactive object has been closed/disposed.
no setterinherited
isError bool

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns true if the status is LxError.
no setter
isIdle bool

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns true if the status is LxIdle.
no setter
isLoading bool

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Alias for isWaiting.
no setter
isSuccess bool

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns true if the status is LxSuccess.
no setter
isWaiting bool

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns true if the status is LxWaiting.
no setter
lastValue → T?

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns the LxStatus.lastValue (the most recent successful value).
no setter
name String?
An optional descriptive name for debugging and profiling.
getter/setter pairinherited
onCancel → void Function()?
Called when the stream is cancelled.
finalinherited
onListen → void Function()?
Called when the stream is listened to.
finalinherited
ownerId String?
The registration key of the owning controller, if applicable.
getter/setter pairinherited
requireValue → T

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Force-retrieves the current value if the status is LxSuccess.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTraceOrNull StackTrace?

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns the stack trace if the status is LxError, otherwise null.
no setter
stream Stream<T>
A Stream that emits the latest value whenever it updates.
no setterinherited
value ↔ T
The current state of the reactive object.
getter/setter pairinherited-getter
valueOrNull → T?

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns the current value if the status is LxSuccess, otherwise null.
no setter
wait Future<T>

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Returns a Future that completes when the operation reaches a terminal state.
no setter

Methods

addListener(void listener()) → void
Adds a listener.
inherited
bind(Stream<T> externalStream) → void
Binds an external stream to this reactive variable.
inherited
call([T? v]) → T
Functional-style update and retrieval.
override
close() → void
Permanently closes the reactive object and releases all internal resources.
inherited
dispose() → void
Disposes the notifier.
inherited
listen(void callback(T value)) LxWorker<T>

Available on LxReactive<T>, provided by the LxReactiveWatchExtensions extension

Executes callback whenever this reactive value changes.
listen(void onSuccess(T value), {void onIdle()?, void onWaiting()?, void onError(Object error)?, dynamic onProcessingError(Object error, StackTrace stackTrace)?}) LxWorker<LxStatus<T>>

Available on LxReactive<LxStatus<T>>, provided by the LxStatusReactiveExtensions extension

Specialized listen for async status that allows handling individual states.
mutate(void mutator(T value)) → void
Mutates the value in place and triggers a refresh.
inherited
named(String name) → R

Available on R, provided by the LxNamingExtension extension

Sets the debug name of this reactive object and returns it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Alias for refresh.
inherited
refresh() → void
Triggers a notification without changing the value.
inherited
register(String ownerId) → R

Available on R, provided by the LxNamingExtension extension

Registers this reactive object with an owner (fluent API).
removeListener(void listener()) → void
Removes a listener.
inherited
setValueInternal(T val, {bool notifyListeners = true}) → void
Internal setter for subclasses (Computed, etc.)
inherited
toString() String
A string representation of this object.
inherited
transform<R>(Stream<R> transformer(Stream<T> stream)) LxStream<R>
Transforms the stream of changes using transformer.
unbind() → void
Unbinds any external stream.
inherited
updateValue(T fn(T val)) → void
Updates the value using a transformation function.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited