Skip to content

Why exist protocols Getable and Postable? #26

@amadeu01

Description

@amadeu01

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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions