Skip to content

Instantly share code, notes, and snippets.

View Mackarous's full-sized avatar
🇨🇦

Andrew Mackarous Mackarous

🇨🇦
View GitHub Profile
@Mackarous
Mackarous / DataTaskPublisher+HTTPResponse.swift
Last active June 15, 2020 07:14
Handy extension on DataTaskPublisher
extension URLSession.DataTaskPublisher {
func tryFilter(httpStatusCode: Int) -> Publishers.TryFilter<Self> {
tryFilter(httpStatusCodes: httpStatusCode..<httpStatusCode+1)
}
func tryFilter(httpStatusCodes: Range<Int>) -> Publishers.TryFilter<Self> {
tryFilter(httpStatusCodes: ClosedRange(httpStatusCodes))
}
func tryFilter(httpStatusCodes: ClosedRange<Int>) -> Publishers.TryFilter<Self> {
### Keybase proof
I hereby claim:
* I am mackarous on github.
* I am mackarous (https://keybase.io/mackarous) on keybase.
* I have a public key ASCA_AtuoQJvbX7n_9mj2UlKutePRnEjs06HZByIbcRAAgo
To claim this, I am signing this object: