Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a new
.scoped
operator on URLRoutingClient that can be used to create scoped clients.This supports a use case where your main client may support a large number of routes and you only want to be able to pass around a client that handles a sub-set of those routes as a dependency.
For instance, imagine a feature domain within a TCA app - your AppEnvironment may hold onto a
URLRoutingClient<AppRoute>
client but your account feature may only need to make requests to account-related routes, so you'd like to pass aURLRoutingClient<AccountRoute>
client to that domain's environment, limiting its scope and making it easier for you to find the right route at the call-site.I debated over whether or not to call this scoped or pullback - I think the shape of this function is a pullback but the term "scope" or "scoped" felt more ergonomic to me in this context.
Also added some basic tests for the client.
Suggestion - consider adding some integration tests of the live implementation using a mock server. There's a few available (I've found
https://github.com/surpher/PactSwift
really easy to use although its use cases extend beyond simply creating a mock server).