EntityState<T, V, K, B> mixin

Use this class with any of the redux state.

Generics: T -> The type of the value i.e the type of value in the map entities. V -> The type of the identifier, should be either int or String. This is usually the identifier of the object that you get from your backend. K -> The type of the state i.e the class of the state. eg. NotificationsState. B -> The builder of the class. eg. NotificationsStateBuilder.

Usage:

abstract class AppNotificationState
   with
       EntityState<AppNotification, int, AppNotificationState,
           AppNotificationBuilder>
   implements
       Built<AppNotificationState, AppNotificationStateBuilder> {
 bool get isLoading;

 BuiltList<int> get ids;

 BuiltMap<int, AppNotification> get entities;

 static Serializer<AppNotificationState> get serializer =>
     _$appNotificationStateSerializer;

 factory AppNotificationState() {
   return _$AppNotificationState((b) => b
     ..isLoading = false
     ..ids = BuiltList<int>().toBuilder()
     ..entities = MapBuilder<int, AppNotification>());
 }

 AppNotificationState._();

 @override
 int getId(AppNotification data) {
   return data.id;
 }
}

Constructors

EntityState()

Properties

entities BuiltMap<V, T>
A Map that keeps all the values in the state. [...]
read-only
ids BuiltList<V>
A list that keeps all the ids of the values in the state. [...]
read-only
hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addAll(List<T> data) → K
This replaces all the previous values of state with the new ones in data. [...]
addMany(List<T> data) → K
This appends the data to the already present entities and ids in the state. [...]
addOne(T data) → K
Added a single entity in the state. [...]
getAll([int sortComparer(T t1, T t2)]) → List<T>
Get all the values in the state as List. [...]
getCount() → int
Get the total count of entities in the state. [...]
getEntities() → Map<V, T>
Get all the values in the state as a Map. [...]
getId(T data) → V
This method must be overridden in the class without the call of super(); [...]
getIds() → List<V>
Getter Methods. These methods are useful when getting values from the state. Get all the ids of the entities as a List. [...]
rebuild(dynamic updates(dynamic B)) → K
removeAll() → K
Empties the whole state. [...]
removeMany(List<V> data) → K
This is used to bulk removal of values from entities and ids. [...]
removeOne(V data) → K
This removes a single value in entities and ids. [...]
updateMany(List<T> data) → K
This updates all the values in data on entities that are present. [...]
updateOne(T data) → K
This is used to update one of the values already present in the entities. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

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