RxFuture<T> class
Reactive async state holder built on Rx and SintStatus.
Automatically transitions between LoadingStatus, SuccessStatus, EmptyStatus, and ErrorStatus, supports stale-while-revalidate via revalidate, and discards stale out-of-order responses when reload or revalidate is called again before an earlier Future completes.
class ProfileController extends SintController {
late final user = rxFuture(() => api.fetchUser());
}
- Inheritance
-
- Object
- Listenable
- ListNotifier
- SintListenable<
SintStatus< T> > - RxImpl<
SintStatus< T> > - Rx<
SintStatus< T> > - RxFuture
- Available extensions
Constructors
-
RxFuture(Future<
T> _loader(), {bool immediate = true, bool isEmpty(T data)?}) -
RxFuture.idle(Future<
T> _loader(), {bool isEmpty(T data)?}) - Creates an RxFuture that starts in EmptyStatus without running the loader until reload or revalidate is invoked.
Properties
- firstRebuild ↔ bool
-
getter/setter pairinherited
- hasEagerListeners → bool
-
Whether this notifier has at least one non-
Computedlistener (Obx,ever,everSync,SintBuilder, or activestreamsubscriber).no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
no setterinherited
- isEmpty → bool Function(T data)?
-
final
- listenersLength → int
-
no setterinherited
-
peek
→ SintStatus<
T> -
Reads the current value without registering a reactive dependency in an
enclosing
ObxorComputedscope.no setterinherited -
rawValue
↔ SintStatus<
T> -
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sentToStream ↔ bool
-
getter/setter pairinherited
-
stream
→ Stream<
SintStatus< T> > -
no setterinherited
- string → String
-
Same as
toString()but using a getter.no setterinherited -
subject
→ StreamController<
SintStatus< T> > -
no setterinherited
-
value
↔ SintStatus<
T> -
The current value of the object.
getter/setter pairinherited
Methods
-
addComputedListener(
SintStateUpdate listener, VoidCallback onMarkCheck) → Disposer -
Internal subscription entry point for
Computed<T>viaNotifyData.inherited -
addError(
Object error, [StackTrace? stackTrace]) → void -
inherited
-
addListener(
SintStateUpdate listener) → Disposer -
Register a closure to be called when the object notifies its listeners.
inherited
-
addListenerId(
Object? key, SintStateUpdate listener) → Disposer -
inherited
-
bindStream(
Stream< SintStatus< stream) → voidT> > -
Binds an existing
Stream<T>to thisRx<T>to keep the values in sync. You can bind multiple sources to update the value. Subscriptions close when this Rx is closed, or when the observing widget which created the binding releases its dependencies.inherited -
call(
[SintStatus< T> ? v]) → SintStatus<T> -
Makes a direct update of value adding it to the Stream
useful when you make use of Rx for custom Types to refresh your UI.
inherited
-
close(
) → void -
Close the Rx Variable
inherited
-
containsListener(
SintStateUpdate listener) → bool -
inherited
-
dispose(
) → void -
override
-
listen(
void onData(SintStatus< T> )?, {Function? onError, void onDone()?, bool? cancelOnError}) → StreamSubscription<SintStatus< T> > -
Calls
callbackwith current value, when the value changes.inherited -
listenAndPump(
void onData(SintStatus< T> event), {Function? onError, void onDone()?, bool? cancelOnError}) → StreamSubscription<SintStatus< T> > -
Returns a StreamSubscription similar to listen, but with the
added benefit that it primes the stream with the current value, rather
than waiting for the next value. This should not be called in
onInitor anywhere else during the build process.inherited -
map<
R> (R mapper(SintStatus< T> ? data)) → Stream<R> -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
propagateComputedCheck(
) → void -
Propagates a lightweight dirty-check mark to downstream
Computed<T>dependents without invoking eager UI/worker listeners.inherited -
refresh(
) → void -
inherited
-
refreshGroup(
Object id) → void -
inherited
-
reload(
{bool keepPreviousData = false}) → Future< SintStatus< T> > - Executes the loader and updates value to the resulting SintStatus.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that the
object notifies.
inherited
-
removeListenerId(
Object id, VoidCallback listener) → void -
inherited
-
reportAdd(
VoidCallback disposer) → void -
inherited
-
reportRead(
) → void -
inherited
-
revalidate(
) → Future< SintStatus< T> > -
Reloads while preserving the latest SintStatus.dataOrNull inside
LoadingStatus (
isRefreshing == true) for stale-while-revalidate UIs. -
run(
Future< T> nextLoader(), {bool keepPreviousData = false}) → Future<SintStatus< T> > -
Replaces the async loader and triggers a fresh reload (retaining
previous data when
keepPreviousDataistrue). -
toJson(
) → dynamic -
Returns the json representation of
value.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
trigger(
SintStatus< T> v) → void -
Following certain practices on Rx data, we might want to react to certain
listeners when a value has been provided, even if the value is the same.
At the moment, we ignore part of the process if we
.call(value)with the same value since it holds the value and there's no real need triggering the entire process for the same value inside, but there are other situations where we might be interested in triggering this.inherited -
update(
SintStatus< T> fn(SintStatus<T> ? val)) → void -
Uses a callback to update value internally, similar to refresh,
but provides the current value as the argument.
Makes sense for custom Rx types (like Models).
inherited
-
watchInObx(
) → void -
Available on Listenable, provided by the SintListenableBridgeExtension extension
Registers this Listenable in the enclosingObxorComputedscope.
Operators
-
operator ==(
Object o) → bool -
This equality override works for _RxImpl instances and the internal
values.
inherited
Static Methods
-
guard<
T> (Future< T> task(), {T? previousData, bool isEmpty(T data)?}) → Future<SintStatus< T> > -
Executes
taskand captures its outcome into a SintStatus without throwing (SuccessStatuson completion,ErrorStatuson exception).