-
Suppose I have two methods that I want to call one after the other. Both can fail and one of them is async. The second call should only be made, when the first cal succeeds. Method 1: Now I would like to have code such as: If the second call was synchronous the chaining with Is there anything I could do to get this to work? Or is there an alternative to chaining the calls with Bind()? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
If DeleteItem would return ValueTask<Fin> then no need for wrapper.
|
Beta Was this translation helpful? Give feedback.
-
There is no You can get a await aff.Run(); You can convert from a fin.ToAff(); Also, be aware that |
Beta Was this translation helpful? Give feedback.
It's worth reading the wiki on how to deal with side-effects and at the
EffectsExamples
sample application. They both mostly focus on using the runtime-supporting version ofAff
andEff
, but most of the capabilities of the runtime versions is also available in the non-runtime versions ofAff
andEff
.Some interesting highlights in the
EffectsExample
code:Main
is simply the running of anAff
monad. So the whole application lives inside an effect. It's useful to think this way, as each application is one big side-effect. It's also useful to think about web-requests or events in this way too.Menu
is the launcher for the various examples