handledOnUpdate method
Describe the callback process to be passed to ModelAdapterDocumentQuery.callback.
This is executed when there is a change in the associated collection or document.
Please take appropriate action according to the contents of update
.
ModelAdapterDocumentQuery.callbackに渡すためのコールバック処理を記述します。
関連するコレクションやドキュメントに変更があった場合、こちらが実行されます。
update
の内容に応じて適切な処理を行ってください。
Implementation
@protected
Future<void> handledOnUpdate(ModelUpdateNotification update) async {
if (update.query != modelQuery) {
return;
}
final val = value;
final filtered = filterOnLoad(ModelFieldValue.fromMap(update.value));
if (filtered.isEmpty) {
_value = null;
} else {
_value = await filterOnDidLoad(fromMap(filtered));
}
if (val != value) {
notifyListeners();
}
}