AppStateGroup class
(en) A class that groups multiple SimpleAppState and RefAppState instances for coordinated batch processing.
When any member of the group calls batch, all members are batched together as a unit. This ensures that UI listeners and state listeners fire only once across the entire group, regardless of how many members are updated.
Members can be registered at construction time or later via add. A state can also join a group by calling SimpleAppState.joinGroup.
(ja) 複数の SimpleAppState および RefAppState インスタンスをグループ化し、 バッチ処理を連動させるクラスです。
グループのいずれかのメンバーが batch を呼ぶと、 グループ全体がひとつの単位としてバッチ処理されます。 これにより、何件のメンバーを更新しても、UIリスナーおよびステートリスナーへの 通知はグループ全体でそれぞれ1回だけ行われます。
メンバーはコンストラクタで登録するか、後から add で追加できます。 また SimpleAppState.joinGroup を呼ぶことでもグループに参加できます。
Usage example:
final simpleState = SimpleAppState();
final refState = RefAppState();
final group = AppStateGroup([simpleState, refState]);
simpleState.batch(() {
simpleSlot.set(1);
refSlot.set(someObject);
});
Constructors
-
AppStateGroup([List<
SimpleAppState> ? states]) - (en) Creates a group, optionally with an initial list of states.
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
-
add(
SimpleAppState state) → void -
(en) Adds a state to this group.
If the state is already a member, this call is ignored.
The state's
SimpleAppState._groupis updated to point to this group. -
batch(
void fn()) → void -
(en) Performs a batch update across all members of this group.
All members are set to batch mode before
fnexecutes. Afterfncompletes, UI listeners and state listeners for all members are flushed once. Members that were already in batch mode before this call are not flushed, preserving any outer batch context. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
SimpleAppState state) → void - (en) Removes a state from this group. If the state is not a member, this call is ignored. After removal, the state resumes independent batch processing.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited