onChildEvent function

Stream<DbChildSnapshot> onChildEvent(
  1. String path, [
  2. DbQuery? query
])

Watches the children of a node, one event per change.

A value listener reports the whole node on every change, so it cannot say which child moved, and cannot report a removal once the node is gone.

Implementation

Stream<DbChildSnapshot> onChildEvent(String path, [DbQuery? query]) =>
    _listenWith(
      path,
      query ?? const DbQuery(),
      'onChildEvent',
      fdbDbChildListen,
      (bytes, seq) {
        final m = (decodeSnapshotValue(bytes) as Map?) ?? const {};
        final type = (m['type'] as int?) ?? 0;
        return DbChildSnapshot(
          event: DbChildEvent.values[type.clamp(0, 3)],
          key: '${m['key'] ?? ''}',
          previousKey: m['prev'] == null ? null : '${m['prev']}',
          value: m['value'],
        );
      },
    );