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

FR: FIRDocumentReference initWithDocumentReference #2653

Closed
1amageek opened this issue Mar 27, 2019 · 4 comments
Closed

FR: FIRDocumentReference initWithDocumentReference #2653

1amageek opened this issue Mar 27, 2019 · 4 comments

Comments

@1amageek
Copy link

1amageek commented Mar 27, 2019

Added initialization of FIRDocumentReference for Codable

Introduction

When FIRDocumentReference conforms to Codable, initialization with Decodable is required.
However, because the initialization method is sealed, it can not conform well.
I understand why the initialization method is sealed. That is the proposal.

@interface FIRDocumentReference : NSObject

/** :nodoc: */
- (instancetype)init
    __attribute__((unavailable("FIRDocumentReference cannot be created directly.")));

Proposed solution

I propose adding an initialization method that receives a FIRDocumentReference.

- (instancetype)initWithDocumentReference:(FIRDocumentReference *)reference;

Usage

extension DocumentReference: Decodable {
    public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        let documentReference: DocumentReference = try container.decode(DocumentReference.self)
        return DocumentReference(documentReference: DocumentReference)
    }
}
@1amageek
Copy link
Author

@paulb777 What do you think about this FR?

@wilhuff
Copy link
Contributor

wilhuff commented Mar 27, 2019

I have a design I'd like to share with you. Could you send me your email address to mcg@firebase.com?

@1amageek
Copy link
Author

@wilhuff OK I send.

@mikelehen
Copy link
Contributor

Thanks for the feedback! We actually have an existing issue discussing Codable support for Firestore over here: #627 So if you have additional feedback, that would probably be the best place for it (or on the doc that @wilhuff has shared with you).

Note that DocumentReference is basically just a path to data and the actual Firestore data is stored in the DocumentSnapshot, and so we've been discussing Codable support in the context of DocumentSnapshot rather than DocumentReference.

@firebase firebase locked and limited conversation to collaborators Oct 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants