ReactiveModel<T> class abstract

A lightweight version of Injected

Mixed-in types
Implementers
Available extensions

Constructors

ReactiveModel()
A lightweight version of Injected
ReactiveModel.create({required Object? creator(), T? initialState, bool? autoDisposeWhenNotUsed})
Create a ReactiveModel
factory

Properties

connectionState ConnectionState
no setter
customStatus Object?
Custom status of the state. Set manually to mark the state with a particular tag to be used in your logic.
getter/setter pairinherited
error → dynamic
The error
no setteroverride
hasData bool
The state is mutated successfully.
no setterinherited
hasError bool
The stats has error
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasObservers bool
Whether the state has listeners or not
no setterinherited
isDone bool
The state is mutated using a stream and the stream is done.
no setterinherited
isIdle bool
The state is initialized and never mutated.
no setterinherited
isStateInitialized bool
no setter
isWaiting bool
The state is waiting for and asynchronous task to end.
no setterinherited
rebuild → _Rebuild<T>

Available on ReactiveModel<T>, provided by the ReactiveModeX extension

listen to the state
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapState SnapState<T>
A snap representation of the state
no setterinherited
state ↔ T
The current state
getter/setter pair
stateAsync Future<T>
The current Async state
getter/setter pair
subscription StreamSubscription?
It is not null if the state is waiting for a Future or is subscribed to a Stream
getter/setter pair

Methods

addCleaner(VoidCallback listener) VoidCallback
Add a callback to be executed when the state is disposed of.
inherited
addObserver({required ObserveReactiveModel listener, bool shouldAutoClean = false, bool isSideEffects = true}) VoidCallback
Add observer to this state.
inherited
cleanState() → void
Clean the state
inherited
dispose() → void
Dispose the state
override
disposeIfNotUsed() → void
Dispose the state if it has no listener
initializeState() FutureOr<T?>
Initialize the state
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Notify observers
inherited
onAll<R>({R onIdle()?, required R onWaiting()?, required R onError(dynamic error, VoidCallback refreshError)?, required R onData(T data)}) → R
Listen to the injected Model and rebuild when it emits a notification.
onOrElse<R>({R onIdle()?, R onWaiting()?, R onError(dynamic error, VoidCallback refreshError)?, R onData(T data)?, required R orElse(T data)}) → R
Listen to the injected Model and rebuild when it emits a notification.
refresh() Future<T?>
Refresh the Injected state. Refreshing the state means reinitialize it and reinvoke its creation function and notify its listeners.
setState(Object? mutator(T s), {SideEffects<T>? sideEffects, StateInterceptor<T>? stateInterceptor, bool shouldOverrideDefaultSideEffects(SnapState<T> snap)?, int debounceDelay = 0, int throttleDelay = 0}) Future<T?>
Mutate the state of the model and notify observers.
setToHasData(dynamic data) → void
Set the state to the data status
setToHasError(dynamic error, {StackTrace? stackTrace, VoidCallback? refresher}) → void
Set the state to the error status
setToIsIdle() → void
Set the state to the idle status
setToIsWaiting() → void
Set the state to the waiting status
toggle() → void

Available on ReactiveModel<bool>, provided by the ReactiveModelBool extension

Toggle the state and notify listeners
toString() String
A string representation of this object.
inherited
whenConnectionState<R>({R onIdle()?, required R onWaiting()?, required R onError(dynamic error)?, required R onData(T data)}) → R

Operators

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