stream method

Future<Stream<StreamEvent>> stream({
  1. String? path,
  2. PrintMode? printMode,
  3. FormatMode? formatMode,
  4. bool? shallow,
  5. Filter? filter,
})

Sends a get requests to the database to stream changes.

Tries to stream the data at path, or the whole virtual root, if not set. The printMode and formatMode can be used to control how data is formatted by the server.

The resulting future will stream various StreamEvents, which provide realtime information about how data is changed in the database. Please note that the first element of every stream will be a StreamEvent.put with the current state of the database at path. All events after that are fired as data is manipulated in the database.

The shallow parameter can be used to help you work with large datasets without needing to download everything. Set this to true to limit the depth of the data returned at a location. If the data at the location is a JSON primitive (string, number or boolean), its value will simply be returned. If the data snapshot at the location is a JSON object, the values for each key will be truncated to true.

If filter is added, that filter will be applied to filter the results returned by the server. See Filter for more details.

Implementation

Future<Stream<StreamEvent>> stream({
  String? path,
  PrintMode? printMode,
  FormatMode? formatMode,
  bool? shallow,
  Filter? filter,
}) async {
  final source = await client.stream(
    _buildUri(
      path: path,
      filter: filter,
      printMode: printMode,
      formatMode: formatMode,
      shallow: shallow,
    ),
  );
  for (final eventType in StreamEventTransformer.eventTypes) {
    source.addEventType(eventType);
  }
  return source.transform(const StreamEventTransformer());
}