StatefulMvvmInstance<State, Input> mixin
Base class for storing data
It contains Store, subscription to EventBus events and cached state Do not forget to call dispose method for instances
If used you need to call initializeStatefulInstance in MvvmInstance.initialize call And call disposeStore in MvvmInstance.dispose call
abstract class BaseBox<State> extends MvvmInstance<dynamic> with StatefulMvvmInstance<State, dynamic> {
String get boxName;
late final hiveWrapper = app.instances.get<HiveWrapper>();
@mustCallSuper
@override
void initialize(Input? input) {
super.initialize(input);
initializeStatefulInstance();
}
@mustCallSuper
@override
void dispose() {
super.dispose();
disposeStore();
}
}
- Superclass constraints
- MvvmInstance<
Input>
- MvvmInstance<
- Mixin applications
Properties
-
allPartsReady
→ Observable<
bool> -
Observable indicating that all parts are connected to this instance
finalinherited
- configuration → MvvmInstanceConfiguration
-
MvvmInstanceConfiguration for this instance
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialState → State
-
Initial state for this instance
no setter
- input ↔ Input
-
Input for this instance
latefinalinherited
- isAsync → bool
-
Getter that returns true if instance contains async parts
or require async initialization
no setterinherited
- isDisposed ↔ bool
-
Flag indicating that this instance is disposed
getter/setter pairinherited
- isInitialized ↔ bool
-
Flag indicating that this instance is fully initialized
getter/setter pairinherited
- isPaused ↔ bool
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
savedStateObject
→ Map<
String, dynamic> -
Model as json to be saved to cache
no setter
- state → State
-
Current
State
objectno setter - stateFulInstanceSettings → StateFulInstanceSettings
-
Settings for state - contains cache id and flags to await initialization if needed
no setter
-
stateStream
→ Stream<
State> -
Stream of all state updates
no setter
Methods
-
changes<
Value> (Value mapper(State state)) → Stream< StoreChange< Value> > -
Stream of changes (a pair of previous and current values of
State
) for givenState
mapper -
checkEventWasReceived(
Type event, {int? count}) → bool -
Returns true if underlying events list contains given event name
inherited
-
cleanupReceivedEvents(
) → void -
Cleans collection of received events
inherited
-
dispose(
) → void -
Base method for instance dispose
inherited
-
disposeStore(
) → void - Closes underlying stream subscriptions for Store and EventBus
-
disposeSub(
) → void -
Closes underlying stream subscription for EventBus
inherited
-
getFullPartConnectorsList(
) → List< PartConnector> -
Returns list of parts
inherited
-
initialize(
Input input) → void -
Base method for instance initialization
inherited
-
initializeAsync(
) → Future< void> -
Base method for async instance initialization
inherited
-
initializeInstanceParts(
) → void -
Adds parts to local collection
inherited
-
initializeInstancePartsAsync(
) → Future< void> -
Adds parts to local collection
inherited
-
initializeStatefulInstance(
) → void -
Initializes underlying Store for given
State
-
initializeStore(
) → void -
Initializes underlying Store for given
State
-
initializeSub(
) → void -
inherited
-
initializeWithoutConnections(
Input input) → void -
Base method for lightweight instance initialization
inherited
-
initializeWithoutConnectionsAsync(
) → Future< void> -
Base method for lightweight async instance initialization
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on<
T> (EventBusSubscriber< T> processor, {bool reactsToPause = false, bool firesAfterResume = true}) → EventBusSubscriber -
Subscribes to event of given type
inherited
-
onAllPartReady(
) → void -
Runs for every async part when it is initialized
inherited
-
onAsyncPartReady(
Type type, int? index) → void -
Runs for every async part when it is initialized
inherited
-
onRestore(
Map< String, dynamic> savedStateObject) → void - Callback to get cache object
-
pauseEventBusSubscription(
) → void -
Sets paused flag to false so events stop processing
inherited
-
restoreCachedStateAsync(
) → Future< void> - Tries to restore cached state
-
restoreCachedStateSync(
) → void - Tries to restore cached state
-
resumeEventBusSubscription(
{bool sendAllEventsReceivedWhilePause = true}) → void -
Resumes events processing
inherited
-
subscribe(
) → List< EventBusSubscriber> -
Map of EventBus events and function to be executed for this events
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updates<
Value> (Value mapper(State state)) → Stream< Value> -
Stream of values for given
State
mapper -
updateState(
State state) → void - Updates state in underlying Store
-
useInstancePart<
InstancePartType extends BaseInstancePart< (dynamic, MvvmInstance> >{int index = 0}) → InstancePartType -
Returns initialized instance part for given type
inherited
-
waitTillEventIsReceived(
Type event, {int? count, Duration timeout = const Duration(seconds: 1)}) → Future< void> -
Waits till given event is received by this instance
inherited
-
wrapChanges<
ChangeValue, Value> ({required ChangeValue changeMapper(State), required Value stateMapper(StoreChange< ChangeValue> ), required Value currentMapper(State)}) → StateStream<Value> - StateStream object for changes with given mapper for instance state
-
wrapUpdates<
Value> (Value mapper(State)) → StateStream< Value> - StateStream object for updates with given mapper for instance state
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited