This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Logger { | |
static let dateFormatter: DateFormatter = { | |
let df = DateFormatter() | |
df.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" | |
return df | |
}() | |
static func log(_ item: String, file: String = #file, line: UInt = #line, function: String = #function) { | |
printLikeRxDebug(item, file, line, function) | |
} | |
static func isMainThread(file: String = #file, line: UInt = #line, function: String = #function) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func synchronize<T>(_ single: Single<T>) -> (element: T?, error: Error?) { | |
var element: T? | |
var error: Error? | |
let condition = NSCondition() | |
condition.lock() | |
_ = single.subscribe({ event in | |
condition.lock() | |
switch event { | |
case .success(let elm): element = elm | |
case .error(let err): error = err |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol RxRequestProtocol { | |
func get<U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, token: String?) -> Observable<U> | |
func get(path: String, query: [String: String]?, token: String?) -> Observable<Void> | |
func post<T: Encodable, U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, body: T, token: String?) -> Observable<U> | |
func post<T: Encodable>(path: String, query: [String: String]?, body: T, token: String?) -> Observable<Void> | |
func put<T: Encodable, U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, body: T, token: String?) -> Observable<U> | |
func put<T: Encodable>(path: String, query: [String: String]?, body: T, token: String?) -> Observable<Void> | |
func delete<U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, token: String?) -> Observable<U> | |
func delete(path: String, query: [String: String]?, token: String?) -> Observable<Void> | |
NewerOlder