parameter using encodable
something like this:
func post<T: Encodable>(params: T) { ... }
@wlgemini this is a good idea. Could you give a concrete example of some data you would want to pass ?
struct Account: Encodable {
let email: String
let password: String
}
struct UserInfo: Decodable { ... }
struct Api: NetworkingService {
func login(account: Account) -> AnyPublisher<UserInfo, Error> {
post("/login", params: account)
}
}
@wlgemini Thanks for the concrete example this indeed looks like something we want to support. Pretty busy at the moment but if you want to take a crack at it through a PR in the meantime, feel free to do so :)
I've created a possible solution to "parameters using encodable" in my fork branch "encodable".
https://github.com/workingDog/Networking/tree/encodable
Basically added the "extension Encodable" in NetworkingService.swift, and change "public typealias Params = [String: Any]"
See README -> "Design a clean api" -> "CRUDApi" for how to use.
It would be good if someone could test this and report back.