Last active
September 8, 2020 17:06
-
-
Save mbrandonw/d6064a2eee32f2e93b015ae611d20583 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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