Effect CommunityEC
Effect Community3y ago
2 replies
brocktho

Understanding Async and errors

So I've experimented more with Effect and feel mostly confident in what I'm doing, I just have one last thing to square away. Throughout my effect code pipeline I do error handling with tryMaps and such but in the end I just receive the result? I think it mostly makes sense because at some point you just want to evaluate "on the happy path", but I don't know if I should be try catching that final runPromise or runSync call.

On the note of runSync vs runPromise, there doesn't seem to be an indication of when an effect is runSync vs runPromise. Maybe this is a mistake in my implementation, but I'll have methods that are definitely async since theyre doing fetches and I write them as tryPromise and evaluate them out, but the final return is just a regular Effect with the proper type definitions. Should I only runPromise if the final function returning the Effect is an async function? Or if I ever use tryPromise do I need to evaluate it with a runPromise?
Was this page helpful?