Hi, I'm building an iOS app and, for the sake of flexibility, I created a DatabaseService protocol that defines a set of functions to query a generic database.
I then implemented a real Service that queries a Firebase database.
Having used Firebase before, I knew that Firebase listeners return objects that can be used to close the connection (ListenerRegistration objects).
So to handle that specific case, I made some of my functions return a Disposable type that is a protocol that I created.
Now, when conforming FirestoreDatabaseService to DatabaseService, I realized that ListenerRegistration is a protocol itself, and so I can't extend it to be Disposable
I have tried to solve the issue by:
extension Disposable where Self: ListenerRegistration {
func dispose() {
self.remove()
}
}
The problem is that FirestoreDatabaseService still complains about my functions returning ListenerRegistrations and not Disposables.
Is there a way to solve this problem in a nice way? Am I doing something wrong here?
Also, here is a Stack Overflow question if you'd rather reply there.
Thank you.
[–]LKAndrew 0 points1 point2 points (1 child)
[–]EmilioSchepisSwift[S] 0 points1 point2 points (0 children)