wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
264 stars 109 forks source link

NetworkClient request to return the URLSessionTask #177

Open markst opened 7 years ago

markst commented 7 years ago

Related to issue #96. I'd like to be able to cancel the network request. If the NetworkClient protocol function were to return the URLSessionTask performed:

func request(method: String, url: URL, payload: Data?, callback: @escaping NetworkClientCallback) -> URLSessionTask

It would be possible to cancel the request upon cancelling the operation:

override public func cancel() {
    super.cancel()
    self.networkTask?.cancel()
}
markst commented 7 years ago

Happy to create a PR if you think this is a good idea.