observe method
void Function()
observe(
- void handler(), {
- @Deprecated('fireImmediately has no effect anymore. It is on by default.') bool? fireImmediately,
Implementation
void Function() observe(
void Function(ChangeNotification<T>) handler, {
@Deprecated('fireImmediately has no effect anymore. It is on by default.')
bool? fireImmediately,
}) {
T? prevValue;
void notifyChange() {
_context.untracked(() {
handler(
ChangeNotification(
type: OperationType.update,
object: this,
oldValue: prevValue,
newValue: value,
),
);
});
}
return autorun((_) {
final newValue = value;
notifyChange();
prevValue = newValue;
}, context: _context).call;
}