EmpireViewModel 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. An EmpireWidget 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 EmpireProperty is changed. The EmpireState the ViewModel is bound to will update itself each time an EmpireProperty value is changed and call the states build function, updating the UI.

Constructors

EmpireViewModel()

Properties

activeTasks List
no setter
busy bool
no setter
empireProps Iterable<EmpireProperty>
Provides a list of EmpireProperty fields in the EmpireViewModel.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addOnErrorEventListener(dynamic onError(ErrorEvent event)) StreamSubscription
Adds an event handler which gets executed each time notifyError is called.
addOnStateChangedListener(dynamic onStateChanged(List<EmpireStateChanged> events)) StreamSubscription
Adds an event handler which gets executed each time an EmpireProperty value is changed.
cancelSubscription(StreamSubscription? subscription) Future<void>
Cancels the subscription. The subscriber will stop receiving events
dispose() → 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
notifyChanges(List<EmpireStateChanged> events) → void
Inform the bound EmpireState that the state of the UI needs to be updated.
notifyError(ErrorEvent event) → void
Inform the bound EmpireState that an error has occurred.
resetAll() → void
Resets the value of all properties defined in the empireProps 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<EmpireProperty, dynamic>> setters) → void
Set multiple EmpireProperty 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