DataTransferService
protocol DataTransferService
데이터 전송 서비스와 관련된 메소드들을 정의하는 프로토콜
- 주로 네트워크 요청을 관리하는 역할
-
Declaration
Swift
typealias CompltionHandler<T> = (Result<T, DataTransferError>) -> Void
-
Decodable Response with Custom Queue Decodable 타입의 응답을 기대하며, 결과를 처리할 때 사용할 커스텀 dispatch queue를 지정할 수 있다. 이는 메인 스레드가 아닌 다른 스레드에서 결과를 처리하고자 할 때 유용
Declaration
Swift
@discardableResult func request<T: Decodable, E: ResponseRequestable>( with endpoint: E, on queue: DataTransferDispatchQueue, completion: @escaping CompltionHandler<T> ) -> NetworkCancellable? where E.Response == T
-
Decodable Response with Main Queue Decodable 타입의 응답을 기대하며, 결과를 처리할 때 메인 dispatch queue를 사용한다. UI 업데이트와 같이 메인 스레드에서 처리해아 하는 작업을 위해 사용한다.
Declaration
Swift
@discardableResult func request<T: Decodable, E: ResponseRequestable>( with endpoint: E, completion: @escaping CompltionHandler<T> ) -> NetworkCancellable? where E.Response == T
-
Void Response with Custom Queue 응답의 본문을 기대하지 않으며 (예: HTTP 상태 코드만 확인), 결과를 처리할 때 사용할 커스텀 dispatch queue를 지정할 수 있다.
Declaration
Swift
@discardableResult func request<E: ResponseRequestable>( with endpoint: E, on queue: DataTransferDispatchQueue, completion: @escaping CompltionHandler<Void> ) -> NetworkCancellable? where E.Response == Void
-
Void Response with Main Queue 응답의 본문을 기대하지 않으며, 결과를 처리할 때 메인 dispatch queue를 사용한다.
Declaration
Swift
@discardableResult func request<E: ResponseRequestable>( with endpoint: E, completion: @escaping CompltionHandler<Void> ) -> NetworkCancellable? where E.Response == Void