transform method

Stream<T> transform({
  1. required DocumentReference<Object?> ref,
})

Transform the given ref to a Stream of Ts. The Stream will emmit new values each time there is a change in the DB.

Implementation

Stream<T> transform({
  required DocumentReference ref,
}) {
  return ref
      .withConverter(
        fromFirestore: _repo.fromSnapshot,
        toFirestore: _repo.toMap,
      )
      .snapshots()
      .map<T?>((_) => _.data())
      .where((item) => item != null)
      .whereType<T>();
}