firebase / firebase/firebase-ios-sdk

[FR]: Making ListenerRegistration Model Objects Sendable

Open
#15,145 7 comments 0 reactions 1 assignee Claimed by @ncooke3 View on GitHub
api: database swift-concurrency type: feature request
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 14h
Merged PRs (30d)
72

Description

### Description

Description

Now as we convert our project to Swift Concurrency and Swift 6 we came across the warning Capture of 'listener' with non-sendable type 'any ListenerRegistration' in a '@Sendable' closure:

```swift
import FirebaseDatabase

func coolStream() -> AsyncStream<[Stuff]>{
return AsyncStream { continuation in
let collection: String = "cool"
let db = Firestore.firestore()
let listener = db.collection(collection)
.addSnapshotListener(
listener: { snapshot, error in
guard let snapshot else {
return
}
let results: [Stuff] = snapshot.documents
.map({ try? $0.data(as: Stuff.self) })
.compactMap({ $0 })
continuation.yield(results)
})

continuation.onTermination = { _ in
listener.remove() // <<<-- ERROR/WARNING Capture of 'listener' with non-sendable type 'any ListenerRegistration' in a '@Sendable' closure
}
}
}
```

To silence this we could add @preconcurrency but we also loose sight of these warnings then.

Therefore my question: Is there a specific timeline for when this model object will become Sendable?

I tested with version 11.7.0 today and still get this.
API Proposal

No response
Firebase Product(s)

Database

### API Proposal

_No response_

### Firebase Product(s)

Firestore

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.