Skip to content
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

WIP: RTDB Swift Combine #7544

Closed

Conversation

mortenbekditlevsen
Copy link
Contributor

This is basically a merge of two other works-in-progress: #6976 and #6568

Just so that we have a place to start experimenting with RTDB/Combine.

@google-cla google-cla bot added the cla: yes label Feb 17, 2021
@peterfriese peterfriese added this to In progress in Combine Support via automation Feb 17, 2021
@peterfriese peterfriese deleted the branch firebase:master April 19, 2021 20:46
Combine Support automation moved this from In progress to Dropped Apr 19, 2021
@peterfriese
Copy link
Contributor

Hi @mortenbekditlevsen -

sorry for closing this. We were expecting any in-flight PRs to automatically retarget to master once we merge combine-main.

Can you do this manually, and re-open the PR?

Thanks,
Peter

@paulb777 paulb777 reopened this Apr 19, 2021
Combine Support automation moved this from Dropped to In progress Apr 19, 2021
@paulb777 paulb777 changed the base branch from combine-main to master April 19, 2021 23:54
@paulb777
Copy link
Member

I reopened and changed the base branch to master. Make sure you resync the local branch.

Combine Support automation moved this from In progress to Dropped Apr 27, 2021
Combine Support automation moved this from Dropped to In progress Apr 27, 2021
@mortenbekditlevsen
Copy link
Contributor Author

I force pushed a commit that just contains the additions that were originally made on this branch. It had become too hard to clean up.

Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally looking good!

I just have a few nit-picky comments/questions. My Combine intuition isn't yet developed enough for the naming questions. Maybe @peterfriese has some suggestions?

Copy link
Contributor

@peterfriese peterfriese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some thoughts to the naming discussion, but would like to hear @ryanwilson's opinion as well.

Also, some doc comments are missing.

@mortenbekditlevsen
Copy link
Contributor Author

Latest commit addresses the latest batch of comments regarding doc comments and adds an overload of observe called valuePublisher as suggested.

@mortenbekditlevsen
Copy link
Contributor Author

Question: #6940 uses Result<Void, Error> for completions that can fail, but have no other parameters.

I initially modeled setValue in FirebaseDatabaseSwift similarly, but I was advised to change this to a completion of Error? instead.

Should we unify this behavior?

@peterfriese @ryanwilson

@paulb777
Copy link
Member

What are the advantages and disadvantages of the two different API styles?

@mortenbekditlevsen
Copy link
Contributor Author

The most important thing is of course the consistency, since the difference between the two is so small.

If I should argue for my favorite (Result<Void, Error>) I'd say that it carries slightly more semantic meaning than Error?.
In the former, the success path is the success case of a Result. In the latter it's the absence of an error.
And similarly, in the former the error value is bound to the failure case of the result - so it's very explicitly a failure and not just some 'random' value.

It's subtle and I'd say that most people would be ok with either choice. :-)

I also personally like the equality between:

a(completion: (Result<Void, Error>) -> Void)

a() -> Future<Void, Error>

a() async throws -> Void

(Even though the returned void in the last case would not be spelled out...)

@mortenbekditlevsen mortenbekditlevsen marked this pull request as ready for review June 14, 2021 10:41
@paulb777
Copy link
Member

paulb777 commented Jun 29, 2021

@mortenbekditlevsen Given the minor differences, I'm fine going with your preference. If something compelling comes up in the future, we can change then.

@ryanwilson
Copy link
Member

@mortenbekditlevsen Given the minor differences, I'm fine going with your preference. If something compelling comes up in the future, we can change then.

SGTM as well, apologies for the delay in response.

@mortenbekditlevsen
Copy link
Contributor Author

@paulb777 Is this PR still relevant for the Swift Modernisation efforts?

It's marked as 'Changes requested', but I can't find any concrete suggestions that are not already addressed.

@paulb777
Copy link
Member

paulb777 commented Dec 1, 2021

@mortenbekditlevsen Sorry for losing track of this PR. It looks like it needs to be rebased or merged with master. @peterfriese Do you see anything else to resolve before merging?

Combine is not in scope for the Swift Modernization first phase, but we'd like to continue working with the community on it.

@peterfriese
Copy link
Contributor

@mortenbekditlevsen Sorry for losing track of this PR. It looks like it needs to be rebased or merged with master. @peterfriese Do you see anything else to resolve before merging?

I'd like to see some sample snippets added to FirebaseCombineSwift/README.md.

Also - if possible - it'd be great to add a sample screen to the SwiftUI example app at Example/CombineSample.

Morten - any chance you could add these? If you're pressed for time, we can merge this and add sample code later.

public extension DatabaseReference {
// MARK: - Setting values on a DatabaseReference

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For new Swift code, we've been using triple-slash comments, see https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseCombineSwift/Sources/Firestore/CollectionReference%2BCombine.swift#L31, for example.

Can you update all comments in this PR accordingly?

@@ -5,7 +5,7 @@

Pod::Spec.new do |s|
s.name = 'FirebaseDatabaseSwift'
s.version = '7.9.0-beta'
s.version = '8.0.0-beta'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be updated.

/// written to the server. This block will not be called while
/// the client is offline, though local changes will be visible
/// immediately.
/** Encode an `Encodable` instance and write it to this Firebase Database location.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment style

s.summary = 'Firebase SDKs testing support types and utilities.'

s.description = <<-DESC
Type declarations and utilities needed for unit testing of the code dependent on Firebase SDKs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to add info that the podspecs are just there for testing. See 397215b#diff-221380d0cac6c2109a93596f5086bc8691024208216ff59d18546a8162162550R7

@ryanwilson
Copy link
Member

Hey @mortenbekditlevsen, I'm going to close this as it hasn't been discussed for >1.5 years and async/await and Observable seem like they're the future. Thanks for working through this and the discussion, let us know if you want us to reopen and start the conversation again.

@ryanwilson ryanwilson closed this Jun 27, 2023
Combine Support automation moved this from In progress to Dropped Jun 27, 2023
@mortenbekditlevsen
Copy link
Contributor Author

I agree that that is a good idea. 😊 I could look into extensions for returning async sequences or an Observable model wrapper type. I’m experimenting with a Live generic wrapper around a Codable model entity that can be returned from RTDB or firestore.

@mortenbekditlevsen mortenbekditlevsen deleted the rtdb-swift-combine branch June 27, 2023 16:25
@firebase firebase locked and limited conversation to collaborators Jul 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Combine Support
  
Dropped
Development

Successfully merging this pull request may close these issues.

None yet

4 participants