Closed brendanlensink closed 3 years ago
I think in this case haven it just be PassthroughSubject<FinalResource, Error> make sense.
You could imagine some weird situations where the "value" of a Combine publisher also including an error might make sense, because errors implicitly terminate publishers, any case where you could logically send multiple errors would need to be represented like that. Say a interface with some retrying where it distinguishes "here's an error I got retrying, could still send another error or a success" vs. "I've stopped retrying and failed permanently". However, I don't think THIS interface is one of those, so I think just doing it the logical and simple way makes sense.
One thing we will need to think about and keep an eye on with this interface once we start using it is if it makes sense to have a different name, functions overloaded by return type are always a little creepy, and if we ended up having to add in a bunch of api.request(/*...*/) as Result<Foo, NetableError>
to disambiguate, that'd be pretty bad. One thing we should try before we 100% commit to this is making sure that if we pull this version into an app that uses Netable and that there are no ambiguities created in existing code by having the two overloads.
For #64
This adds a pretty simple second
request
function that returns a PassthroughSubject<FinalResource, NetableError>.I had considered returning PassthroughSubject<Result<FinalResource, NetableError>, Never>(), since it more closely matches our other request function and leverages
Result
, but I think it makes more sense to match Combine. Is that reasonable?