Dynamic URL Handling in an HTTP Client Service with Effect Typescript
I have an HTTP Client described as a Service with many methods, used to hit services implementing the same API.
Now, in the Effect where I use this client the actual domain keeps changing depending on some data it parses that determines which server we're going to hit, so the URL prefix for the HttpClient instance is dynamic. One option would be for me to add this URL as a parameter for every single one of these methods, but I'd rather it just be specified the moment I instantiate the client so I can close over it in the implementation.
I have already tried setting up a dependency in this Service and providing it within the Effect after the URL has been determined, but at least in my attempt that just propagates the dependency through my Effect, which makes no sense.
So I'm reaching out: How can I achieve this?
Now, in the Effect where I use this client the actual domain keeps changing depending on some data it parses that determines which server we're going to hit, so the URL prefix for the HttpClient instance is dynamic. One option would be for me to add this URL as a parameter for every single one of these methods, but I'd rather it just be specified the moment I instantiate the client so I can close over it in the implementation.
I have already tried setting up a dependency in this Service and providing it within the Effect after the URL has been determined, but at least in my attempt that just propagates the dependency through my Effect, which makes no sense.
So I'm reaching out: How can I achieve this?
