ObservableModel class

A Gadget used to store the global state of the application.

For each value provided to the ObservableModel, a relative GadgetSubject is created and stored in the internal _subjectMap. This system represents the fundamental building block of the reactive state management mechanism behind Flutter Gadgets. By using GadgetSubjects, SubscriberGadgets can watch the generated streams and dynamically rebuild whenever a new value is added or removed to one stream.

An ObservableModel instance is automatically created and encapsulated in a Service by AppGadget during initialization.

Constructors

ObservableModel()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

closeAllSubjects() → void
Closes all the subjects stored in the map.
dispose() → void
Closes all the subjects and clears the _subjectMap.
getSubject<T>({String? token}) → GadgetSubject<T?>
Retrieves a specific GadgetSubject from the map.
getValue<T>({String? token}) → T?
Retrieves the current value available in the relative GadgetSubject stored in the map. The map key is automatically generated using the toValueKey function.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyFor<T>({String? token}) → void
Notifies the change of the internal state of a value stored in a GadgetSubject.
putValue<T>({required T? value, String? token}) → void
Puts a value in the specified GadgetSubject stored in the map.
removeValue<T>({bool closeSubject = false, String? token}) → void
Puts a null value in the specified GadgetSubject stored in the map.
safelyRemoveValue<T>({bool closeSubject = false, String? token}) → void
Acts like removeValue, but doesn't throw an exception if the specified GadgetSubject is null.
toString() String
A string representation of this object.
override
updateValue<T>({required Update<T> updateFunction, T? updateIfNull, String? token}) → T
Updates the internal state of a value using a given Update function.

Operators

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