Created
May 25, 2018 17:31
-
-
Save shmidt/799dec1ae5266252f4c999c951bdc079 to your computer and use it in GitHub Desktop.
IPAPI+ReactiveKit
This file contains 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
// | |
// IPAPI+ReactiveKit.swift | |
// Created by Dmitry Shmidt on 5/25/18. | |
// | |
import IPAPI | |
import ReactiveKit | |
extension Service{ | |
@discardableResult open func fetch(query: String? = nil, fields: [Result.Field]? = nil, language: String? = nil) -> Signal<Service.Result, Service.Error> | |
{ | |
return Signal { [weak self] observer in | |
let task = self?.fetch(query: query, fields: fields, language: language, completion: { result, error in | |
if let error = error as? Service.Error{ | |
observer.failed(error) | |
}else if let result = result{ | |
observer.next(result) | |
observer.completed() | |
} | |
}) | |
return BlockDisposable { | |
task?.cancel() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment