subscribeToDataChanges method

  1. @override
UnsubscribeFunction subscribeToDataChanges(
  1. ChangeCallback callback
)
override

Reactive hooks then subscribe to "data has actually changed" notifications, using the info to trigger re-queries, if the changes affect databases and tables that their queries depend on. This then trigger re-rendering iff the query results are actually affected by the data changes.

Implementation

@override
UnsubscribeFunction subscribeToDataChanges(ChangeCallback callback) {
  void wrappedCallback(ChangeNotification notification) {
    if (_hasDbName(notification.dbName)) {
      callback(notification);
    }
  }

  final eventListener =
      EventListener(EventNames.actualDataChange, wrappedCallback);
  _subscribe(eventListener);

  return () => _unsubscribe(eventListener);
}