-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Combine support to Firestore #6960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updating copyright notice from 2020 down to 2019
Combine support for Firestore
|
In general, Firestore (and Firebase more broadly) have tried to avoid baking in any strong preference for any specific UI or data processing frameworks to our base SDKs. We provide the building blocks you can use for using the API simply without requiring users to necessarily go learn additional, potentially complex frameworks. We also want to avoid giving preference to one framework over another at this layer. This is why in the JavaScript SDK, AngularFire and EmberFire are separate packages from the base SDK. Combine is a bit of an interesting case because unlike the other examples, it's built into platform. I'm still inclined to exclude it because it adds additional methods that complicate the interface even if all you wanted was Codable support when you added It seems like this might be better off in a separate FirebaseFirestoreCombine package that lives in FirebaseExtended. @ryanwilson @peterfriese @morganchen12 thoughts? |
|
+1, I lean toward making it a separate framework as well. If you want to not worry at all about your Combine extension being opinionated, you could host it in your own repository outside of Firebase entirely and then submit a pull request to add it to http://firebaseopensource.com/. |
|
@wilhuff I think should be considered also the fact SwiftUI data flow is based on Combine. Since Combine principal feature is composability, the best would be most firebase components to adopt it, so the ideal, in my opinion, would be a separate package FirebaseCombine, that activate Combine methods, (if present) for each component installed. |
|
Hi @lorenzofiamingo - we've integrated the groundwork for Combine into Would you be open to updating this PR according to the decisions we laid out in this file? As #6940 hasn't been merged yet, I would suggest mapping results manually (like here, for example). Don't forget to add tests for any new code. Thanks, |
|
Hi @peterfriese! I spied on your commits as they were published and they are really cool! At the moment I'm in the exams period at university, but I'll do my best as soon as I got some spare time. |
Good luck on your exams @lorenzofiamingo! 😄 take your time, studying comes first 😉 |
|
Closed in favor of #7623 |
I know Combine support for Firebase is not even discussed, so please feel free to ignore me. I make this pull request only in the remote case it could be useful to you.
Discussion
Implementation based on this Result support implementation: Add Result argument type support to Firestore methods closures #6940
Some info regarding my proposal (I have doubts on some points):
URLSessionmethoddataTaskthat becomesdataTaskPublisher.Future. I decided to leave the Future return type to make more evident the fact that after the emission of the first value the publisher receives a completion.addDocumentinCollectionReferencemethod already has a return type. Instead of returning a tuple, I decided to pass theDocumentReferenceto the publisher's output, so the reference will be available only asynchronously. In my opinion, if you want to use a publisher for this task, is more useful to have a clean return type than handle it synchronously. This considering the fact that you can directly create a new reference and then set data. Maybe creating a second method with a tuple as a return type would be useful.Other approaches:
Publisher/Subject/ConnectablePublisherprotocols. With this approach would be nice to group different methods in the same publisher using Combine backpressure. In this way, for example, depending on subscriber request demand, different methods could be called.myreference.fetcher.publisher(continously: true)Testing