AsyncUpdateScheduler class
An utility class for notifying ~once per VM turn to do an update action.
This is to handle patterns where many properties may be updated, synchronously, such as through Angular property setters, but the user would like to wait and apply an update once after they are all called.
Example: class Foo { String _bar; String _baz; AsyncUpdateScheduler _scheduler;
Foo() {
_scheduler = new AsyncUpdateScheduler(_doExpensiveWork);
}
String get bar => _bar;
set bar(String bar) {
if (bar != _bar) {
_bar = bar;
_scheduler.scheduleUpdate();
}
}
String get baz => _baz;
set baz(String baz) {
if (baz != _baz) {
_baz = baz;
_scheduler.scheduleUpdate();
}
}
// Will only be called once, even if both bar and baz are set.
void doExpensive() { ... }
}
Constructors
- AsyncUpdateScheduler([OnUpdateCallback? _updateCallback])
- Creates a new scheduler, optionally with a callback.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scheduleUpdate(
) → void - Asynchronously schedule an action for later in the VM turn.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited