What I have so far is this:
I've defined
typealias
completion handlertypealias UserCompletionHandler = (_ object: User?, _ error: ApiError?) -> Void
And I've created a service function that is using this typealias
func login(email: String, password: String, completion: UserCompletionHandler) { // ... // this part here handles API call and parsing logic // ... completion(user, nil) }
What I want to achieve is to have more readable completion callback with parameters by introducing named arguments. Idea is to end up with this:
completion(object: user, error: nil)
Or even better to make error parameter optional, so I can just call
completion(object: user)
Issue is that I can't find a way to change typealias
definition to achieve this.