Skip to content

Commit cd48b85

Browse files
committed
Return stream as an AsyncSequence
1 parent 86aea72 commit cd48b85

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Firestore/Swift/Source/AsyncAwait/DocumentReference+AsyncSequence.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ public extension DocumentReference {
2626
/// An asynchronous sequence of document snapshots.
2727
///
2828
/// This stream emits a new `DocumentSnapshot` every time the underlying data changes.
29-
var snapshots: AsyncThrowingStream<DocumentSnapshot, Error> {
29+
@available(iOS 18.0, *)
30+
var snapshots: some AsyncSequence<DocumentSnapshot, Error> {
3031
return snapshots(includeMetadataChanges: false)
3132
}
3233

3334
/// An asynchronous sequence of document snapshots.
3435
///
3536
/// - Parameter includeMetadataChanges: Whether to receive events for metadata-only changes.
3637
/// - Returns: An `AsyncThrowingStream` of `DocumentSnapshot` events.
37-
func snapshots(includeMetadataChanges: Bool) -> AsyncThrowingStream<DocumentSnapshot, Error> {
38+
@available(iOS 18.0, *)
39+
func snapshots(includeMetadataChanges: Bool) -> some AsyncSequence<DocumentSnapshot, Error> {
3840
return AsyncThrowingStream { continuation in
3941
let listener = self
4042
.addSnapshotListener(includeMetadataChanges: includeMetadataChanges) { snapshot, error in

Firestore/Swift/Source/AsyncAwait/Query+AsyncSequence.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ public extension Query {
2626
/// An asynchronous sequence of query snapshots.
2727
///
2828
/// This stream emits a new `QuerySnapshot` every time the underlying data changes.
29-
var snapshots: AsyncThrowingStream<QuerySnapshot, Error> {
29+
@available(iOS 18.0, *)
30+
var snapshots: some AsyncSequence<QuerySnapshot, Error> {
3031
return snapshots(includeMetadataChanges: false)
3132
}
3233

3334
/// An asynchronous sequence of query snapshots.
3435
///
3536
/// - Parameter includeMetadataChanges: Whether to receive events for metadata-only changes.
3637
/// - Returns: An `AsyncThrowingStream` of `QuerySnapshot` events.
37-
func snapshots(includeMetadataChanges: Bool) -> AsyncThrowingStream<QuerySnapshot, Error> {
38+
@available(iOS 18.0, *)
39+
func snapshots(includeMetadataChanges: Bool) -> some AsyncSequence<QuerySnapshot, Error> {
3840
return AsyncThrowingStream { continuation in
3941
let listener = self
4042
.addSnapshotListener(includeMetadataChanges: includeMetadataChanges) { snapshot, error in

0 commit comments

Comments
 (0)