Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Last active September 8, 2020 17:06
Show Gist options
  • Save mbrandonw/d6064a2eee32f2e93b015ae611d20583 to your computer and use it in GitHub Desktop.
Save mbrandonw/d6064a2eee32f2e93b015ae611d20583 to your computer and use it in GitHub Desktop.
struct StoreManagerClient {
var load: (String) -> AnyPublisher<(Data, URLResponse), URLError>
func load<Output: Decodable>(objectID: String) -> AnyPublisher<Output, Error> {
self.load(objectId)
.decode(type: Output.self, decoder: JSONDecoder())
.eraseToAnyPublisher()
}
}
extension StoreManagerClient {
static let live = Self(
load: { objectId in
URLSession.shared.dataTaskPublisher(...)
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment