LxStream<T> class
A reactive wrapper for a Stream.
LxStream transforms a standard Dart Stream into a reactive object that tracks its state using LxStatus. It is designed for fine-grained UI updates and follows a lazy-subscription model: the source stream is only listened to when the LxStream itself has active observers.
Key Features
- Status Tracking: Automatically translates stream events into LxSuccess and errors into LxError.
- Lazy Subscription: Minimizes resource usage by only connecting to the source when necessary.
- Rx-like Transformations: Provides map, where, and asyncMap utilities that return new reactive streams.
Usage
final messages = channel.stream.lx;
LWatch(() => ListView(children: messages.value.lastValue ?? []));
- Inheritance
-
- Object
- LevitReactiveNotifier
- LxBase<
LxStatus< T> > - LxStream
- Available extensions
Constructors
Properties
- computedValue → T
-
Available on LxReactive<
Alias for requireValue.LxStatus< , provided by the LxStatusReactiveExtensions extensionT> >no setter - errorOrNull → Object?
-
Available on LxReactive<
Returns the current error if the status is LxError, otherwiseLxStatus< , provided by the LxStatusReactiveExtensions extensionT> >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<
Alias for isSuccess.LxStatus< , provided by the LxStatusReactiveExtensions extensionT> >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<
ReturnsLxStatus< , provided by the LxStatusReactiveExtensions extensionT> >trueif the status is LxError.no setter - isIdle → bool
-
Available on LxReactive<
ReturnsLxStatus< , provided by the LxStatusReactiveExtensions extensionT> >trueif the status is LxIdle.no setter - isLoading → bool
-
Available on LxReactive<
Alias for isWaiting.LxStatus< , provided by the LxStatusReactiveExtensions extensionT> >no setter - isSuccess → bool
-
Available on LxReactive<
ReturnsLxStatus< , provided by the LxStatusReactiveExtensions extensionT> >trueif the status is LxSuccess.no setter - isWaiting → bool
-
Available on LxReactive<
ReturnsLxStatus< , provided by the LxStatusReactiveExtensions extensionT> >trueif the status is LxWaiting.no setter - lastValue → T?
-
Available on LxReactive<
Returns the LxStatus.lastValue (the most recent successful value).LxStatus< , provided by the LxStatusReactiveExtensions extensionT> >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<
Force-retrieves the current value if the status is LxSuccess.LxStatus< , provided by the LxStatusReactiveExtensions extensionT> >no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stackTraceOrNull → StackTrace?
-
Available on LxReactive<
Returns the stack trace if the status is LxError, otherwiseLxStatus< , provided by the LxStatusReactiveExtensions extensionT> >null.no setter -
status
→ LxStatus<
T> -
Returns the current LxStatus of the stream.
no setter
-
stream
→ Stream<
LxStatus< T> > -
A Stream that emits the latest value whenever it updates.
no setterinherited
-
value
→ LxStatus<
T> -
The current state of the reactive object.
no setterinherited
- valueOrNull → T?
-
Available on LxReactive<
Returns the current value if the status is LxSuccess, otherwiseLxStatus< , provided by the LxStatusReactiveExtensions extensionT> >null.no setter -
valueStream
→ Stream<
T> -
Returns the raw stream of values, unwrapped from LxStatus.
no setter
-
wait
→ Future<
T> -
Available on LxReactive<
Returns a Future that completes when the operation reaches a terminal state.LxStatus< , provided by the LxStatusReactiveExtensions extensionT> >no setter
Methods
-
addListener(
void listener()) → void -
Adds a listener.
inherited
-
asyncMap<
E> (FutureOr< E> convert(T event)) → LxStream<E> - Asynchronously transforms each data event.
-
bind(
Stream< LxStatus< stream) → voidT> > -
Binds an external stream to this reactive variable.
override
-
bindStream(
Stream< T> stream) → void - Replace the current source stream with a new one.
-
call(
) → LxStatus< T> -
Functor-like call to get value.
inherited
-
close(
) → void -
Permanently closes the reactive object and releases all internal resources.
override
-
dispose(
) → void -
Disposes the notifier.
inherited
-
distinct(
[bool equals(T previous, T next)?]) → LxStream< T> - Skips duplicate events.
-
expand<
R> (Iterable< R> convert(T element)) → LxStream<R> - Expands each event into an iterable of events.
-
fold<
R> (R initialValue, R combine(R previous, T element)) → LxFuture< R> - Folds the stream into a single LxFuture result.
-
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<
Specialized listen for async status that allows handling individual states.LxStatus< , provided by the LxStatusReactiveExtensions extensionT> > -
map<
R> (R convert(T event)) → LxStream< R> -
Transforms each data event with
convert. -
mutate(
void mutator(LxStatus< T> value)) → void -
Mutates the value in place and triggers a refresh.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify(
) → void -
Alias for refresh.
inherited
-
reduce(
T combine(T previous, T element)) → LxFuture< T> -
Reduces the stream to a single value using
combine. -
refresh(
) → void -
Triggers a notification without changing the value.
inherited
-
removeListener(
void listener()) → void -
Removes a listener.
inherited
-
setValueInternal(
LxStatus< T> val, {bool notifyListeners = true}) → void -
Internal setter for subclasses (Computed, etc.)
inherited
-
toString(
) → String -
A string representation of this object.
override
-
transform<
R> (Stream< R> transformer(Stream<LxStatus< stream)) → LxStream<T> >R> -
Transforms the status sequence into a new LxStream.
inherited
-
unbind(
) → void -
Unbinds any external stream.
override
-
updateValue(
LxStatus< T> fn(LxStatus<T> val)) → void -
Updates the value using a transformation function.
inherited
-
where(
bool test(T event)) → LxStream< T> -
Filters events based on
test.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited