Skip to content

[FR]: Making ListenerRegistration Model Objects Sendable #15145

@realmtai

Description

@realmtai

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:

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions