Replies: 1 comment
-
Doh...I should've realized that there is a public static Aff<T> Get<T>(HttpClient client, string url, ILogger logger) =>
use(
GetHttpResponse(client, url) | CatchAndLogError<HttpResponseMessage>(logger, url),
response =>
DeserializeFromJson<T>(response) | CatchAndLogError<T>(logger, url)
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I am starting to try to understand Aff/Eff but am struggling with how to deal with side-effects that return an IDisposable that I need to use in future functions, but also want to be sure to dispose in both success and failure cases. I am staying away from Runtimes for now until I at least get my head around some of the simpler concepts.
I started with something like this, based on some other code that I found here:
But then I realized that
Dispose
would only execute in the success path; any errors before then would cause the computation to stop andDispose
to not be called.The simplest thing might be to wrap
GetHttpResponse
andDeserializeFromJson
in a single Aff to make resource disposal easier, but I want to keep them separate if possible.I found some other ideas like a "Use" function below, but in tracing the logs, the finally block isn't being executed in an error case. I assume that's because the Bind and
return f(a).Run()
isn't the correct concept, but I'm a little stuck. Any best practices on how to deal with something like this?Beta Was this translation helpful? Give feedback.
All reactions