let response = deferred.getCompleted() if let result = response as? Response.Success { if let success = result as! LoginSuccess { doSomething(user: success.user) } } }) • APIΫϥΠΞϯτΛimport • Deffered͔ΒgetCompleted()Ͱ݁ՌΛऔΓग़͢ • getCompleted()͕Any?Λฦ͢ͷͰΩϟετ
-> Future<Success, Fail> { return Future<Success, Fail> { promise in self.invokeOnCompletion( cause in if let cause = cause { promise(.failure(Fail(cause))) return } if let completion = self.getCompleted() as? Response.Success { let result = completion as! Success.Type promise(.success(result)) } } )} }
deferred.invokeOnCompletion(cause in let response = deferred.getCompleted() if let result = response as? Response.Success { if let success = result as! LoginSuccess { doSomething(user: success.user) } } }) • After import InhouseClientSwifty client.login(email: "[email protected]",password: "password") .sink(receiveValue: { value in doSomething(user: value.user) }, receiveCompletion { completion in handle(completion) })