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

Why exist protocols Getable and Postable? #26

Open
amadeu01 opened this issue Feb 12, 2018 · 3 comments
Open

Why exist protocols Getable and Postable? #26

amadeu01 opened this issue Feb 12, 2018 · 3 comments

Comments

@amadeu01
Copy link
Contributor

Postable and Postable are basically the same thing.

public protocol Getable {
    @discardableResult
    func get<T: Decodable>(url: String,
                           onComplete: @escaping OnComplete<T>) -> Cancellable
    @discardableResult
    func get<T: Decodable>(url: URL,
                           onComplete: @escaping OnComplete<T>) -> Cancellable
    @discardableResult
    func get<T: Decodable, U: Encodable>(url: String, query: U,
                                         onComplete: @escaping OnComplete<T>) -> Cancellable
    @discardableResult
    func get<T: Decodable, U: Encodable>(url: URL, query: U,
                                         onComplete: @escaping OnComplete<T>) -> Cancellable
}
protocol Postable {
    @discardableResult
    func post<T: Decodable>(url: String,
                            onComplete: @escaping OnComplete<T>) -> Cancellable
    @discardableResult
    func post<T: Decodable>(url: URL,
                            onComplete: @escaping OnComplete<T>) -> Cancellable
    @discardableResult
    func post<T: Decodable, U: Encodable>(url: String, body: U,
                                          onComplete: @escaping OnComplete<T>) -> Cancellable
    @discardableResult
    func post<T: Decodable, U: Encodable>(url: URL, body: U,
                                          onComplete: @escaping OnComplete<T>) -> Cancellable
}

Why do not make one protocol and then extend it if necessary?

@ronanrodrigo
Copy link
Owner

The initial idea is to restrict all the protocols and concrete implementations to do well just one thing. This could overflow in the future. But, when this occurs we will plan how to avoid this.

@amadeu01
Copy link
Contributor Author

amadeu01 commented Mar 12, 2018

I'm asking due to their similarities.
It seems like those classes are essentially the same.
Why do not have something between these two classes, and extend them if necessary?

@ronanrodrigo
Copy link
Owner

Yes, they are similar. And we could make a plan to aggregate common stuffs. But this is not the top-level issue now. I will keep this issue open so we can plan this here 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants