ImmutableModel<S> class

The main class used to define immutable state models.

Inheritance
Annotations

Constructors

ImmutableModel(Map<String, ModelType<ModelType, dynamic>> modelMap, {ModelMapValidator modelValidator, S initialState, bool strictUpdates = false})
Constructs a class used to define an immutable state model.
factory

Properties

currentState → S
The current state
read-only
fieldLabels Iterable<String>
read-only
hashCode int
The hash code for this object.
read-onlyinherited
inner ModelInner
The underlying ModelInner.
read-only
modelMap Map<String, ModelType<ModelType, dynamic>>
The map between field labels and the current ModelType models.
read-only
numberOfFields int
read-only
props List<Object>
The list of properties that will be used to determine whether two instances are equal.
read-onlyoverride
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
stringify bool
If set to true, the toString method will be overridden to output this instance's props.
read-onlyinherited

Methods

fromJson(Map<String, dynamic> jsonMap) ImmutableModel<S>
Deserializes the values in jsonMap and updates the current model values with them.
getModel(String fieldLabel) ModelType<ModelType, dynamic>
Returns the ModelType model specified by fieldLabel.
getValue(String fieldLabel) → dynamic
Returns the value of the model specified by fieldLabel.
hasModel(String fieldLabel) bool
join(ImmutableModel other, {bool strictUpdates = false}) ImmutableModel<S>
Joins other to this and creates a new ImmutableModel from the result.
mergeFrom(ImmutableModel<S> other) ImmutableModel<S>
Merges other into this.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
resetAll() ImmutableModel<S>
Resets all the models in this to their ModelType.initial instance.
resetAndTransitionTo(S nextState) ImmutableModel<S>
Resets all the models in this to their ModelType.initial instance and sets the currentState to nextState.
resetFields(List<String> fieldLabels) ImmutableModel<S>
Resets the models specified by fieldLabels to their ModelType.initial instance.
selectModel<V>(ModelSelector<V> selector) ModelType<ModelType, dynamic>
Returns the ModelType model selected by selector.
selectValue<V>(ModelSelector<V> selector) → V
Returns the value of the model selected by selector.
toJson() Map<String, dynamic>
Returns a Map between the field labels and the current, serialized model values (using ModelType.asSerializable).
toJsonDelta(ImmutableModel<S> other) Map<String, dynamic>
Returns a Map between the field labels and the current, serialized model values, based on the delta from other to this.
toString() String
A string representation of this object.
override
transitionTo(S nextState) ImmutableModel<S>
Sets the currentState to nextState.
transitionToAndUpdate(S nextState, Map<String, dynamic> updates) ImmutableModel<S>
Sets the currentState to nextState and updates the models values specified by updates.
update(Map<String, dynamic> updates) ImmutableModel<S>
Updates the current model values with those specified in updates.
updateIfIn(Map<String, dynamic> updates, S inState) ImmutableModel<S>
Updates the current model values with those specified in updates, if currentState == inState.
updateTo(ImmutableModel<S> other) ImmutableModel<S>
Updates the underlying ModelInner with the one in other and the currentState will be set to that of other.
updateWithInner(ModelInner other) ImmutableModel<S>
Updates the underlying ModelInner with the one in other and the currentState will be set to that of other.
updateWithSelector<V>(ModelSelector<V> selector, dynamic update) ImmutableModel<S>
Updates the field selected by selector with update.
updateWithSelectorIfIn<V>(ModelSelector<V> selector, dynamic update, S inState) ImmutableModel<S>
Updates the field selected by selector with update if currentState is inState.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String fieldLabel) → dynamic
Returns the value of the model specified by fieldLabel, except if the model is a ModelInner, in which case the ModelInner model will be returned, not its value.