CurrentStateViewModel class abstract

A ViewModel is an abstraction of the view it is bound to and represents the current state of the data in your model.

This is where any logic that manipulates your model should be. In Flutter the CurrentWidget, or in Jaspr the CurrentComponent, and it's accompanying state always has access to it's view model via the viewModel property.

Update events are automatically emitted whenever the value of an CurrentProperty is changed. The state the ViewModel is bound to will update itself each time an CurrentProperty value is changed and call the states build function, updating the UI.

Constructors

CurrentStateViewModel()

Properties

activeTasks → List
no setter
assignedTo → int?
The state identifier that the view model is currently assigned to
no setter
assignedToState → bool
Whether the view model has already been assigned to a state
no setter
busy → bool
Whether the view model is currently busy performing a long running task. Can be used by the UI to show a loading indicator or prevent user interaction.
no setter
currentBindings → Iterable<CurrentViewModelBinding>
Provides a list of helper bindings that should attach after the view model has assigned itself to all currentProps.
no setter
currentProps → Iterable<CurrentProperty>
Provides a list of CurrentProperty fields in the CurrentStateViewModel.
no setter
disposed → bool
no setter
hashCode → int
The hash code for this object.
no setterinherited
isDirty → bool
Whether any of the properties defined in currentProps have a value that is different from their original value.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addAnyErrorEventListener(void onError(ErrorEvent event), {void onInternalError(Object error, StackTrace stackTrace)?}) → StreamSubscription<ErrorEvent>
Adds an event handler for all ErrorEvent values
addAnyStateChangedListener(void onStateChanged(CurrentStateChanged event), {bool filter(CurrentStateChanged event)?, String? propertyName}) → StreamSubscription<CurrentStateChanged>
Adds an event handler for all CurrentStateChanged events.
addBusyStatusChangedListener(void onChanged(BusyStatusChanged event), {dynamic busyTaskKey}) → StreamSubscription
Subscribes to changes in the busy status of the view model.
addOnErrorEventListener<T extends ErrorEvent>(void onError(T event), {void onInternalError(Object error, StackTrace stackTrace)?}) → StreamSubscription<T>
Adds an event handler which gets executed each time notifyError is called.
addStateChangedListener<T extends CurrentStateChanged>(void onStateChanged(T event), {bool filter(T event)?, String? propertyName}) → StreamSubscription<T>
Adds an event handler which gets executed each time an event of type T is added to the state stream.
assignTo(int widgetHash) → void
Creates associates the view model with a specific state via the states hash code.
cancelSubscription(StreamSubscription? subscription) → Future<void>
Cancels the subscription. The subscriber will stop receiving events
dispose() → void
See disposeViewModel.
disposeViewModel() → void
Closes the state and error streams and removes any listeners associated with those streams.
doAsync<T>(Future<T> work(), {dynamic busyTaskKey}) → Future<T>
Executes a long running task asynchronously.
isTaskInProgress(dynamic busyTaskKey) → bool
Checks if the view model is busy working on a specific task.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyChange(CurrentStateChanged event) → void
Inform the bound state that the state of the UI needs to be updated with a single event.
notifyChanges(List<CurrentStateChanged> events) → void
Inform the bound state that the state of the UI needs to be updated.
notifyError(ErrorEvent event) → void
Inform the bound state that an error has occurred.
notifyListeners() → void
Notifies components attached to this view model that the state has changed and they should update themselves.
releaseFrom(int widgetHash) → void
Releases the current state assignment when it matches the provided state identifier.
resetAll() → void
Resets the value of all properties defined in the currentProps list to their original value.
setBusy({dynamic busyTaskKey}) → void
Sets the busy status to true
setBusyStatus({required bool isBusy, dynamic busyTaskKey}) → void
Explicitly updates the current busy status of the view model.
setMultiple(List<Map<CurrentProperty, dynamic>> setters) → void
Set multiple CurrentProperty values, but only trigger a single state change
setNotBusy({dynamic busyTaskKey}) → void
Sets the busy status to false
toString() → String
A string representation of this object.
inherited

Operators

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