writefreely-swift/docs/URLSessionProtocol.md

22 lines
471 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# URLSessionProtocol
Define requirements for `URLSession`s here for dependency-injection purposes (specifically, for testing).
``` swift
public protocol URLSessionProtocol
```
## Requirements
### DataTaskResult
``` swift
typealias DataTaskResult = (Data?, URLResponse?, Error?) -> Void
```
### dataTask(with:completionHandler:)
``` swift
func dataTask(with request: URLRequest, completionHandler: @escaping DataTaskResult) -> URLSessionDataTaskProtocol
```