So I'm using Appwrite as a backend for my application.
In my repository, I want to create a function along the lines of
func listenToAltersForUser(userId: String) -> PassthroughSubject(?) {
subscription = appwriteClient.realtime(....) { event in
if (event.isForUser) {
sink.send(event)
}
}
}
So all the examples I can find on the internet use traditional networking calls with pre-built extensions to convert a request to a stream. However I'm not making networking calls directly.
I have a function that produces a callback on updates, and I have no idea how to create a subscription that can be listened to. I don't want to create a global passthrough subject for the class, because there could be multiple, and if the userId changes than I need to create a new subscription.
I know in kotlin I'd use callBackFlow
but I'm newer to swift.