You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import ConcurrentTask as CT exposing (ConcurrentTask)
finallyDo : ConcurrentTask e a -> ConcurrentTask e b -> ConcurrentTask e a
finallyDo secondTask firstTask =
firstTask
|> CT.onError (\e -> secondTask |> CT.andThenDo (CT.fail e))
|> CT.andThenDo secondTask
Similar to Javascripts try-catch-finally statement. For example, I'm using finallyDo to make sure unlockResource gets called in both, the success and failure case:
callInsideLock : ConcurrentTask e a -> ConcurrentTask e b
callInsideLock task =
lockResource
|> CT.andThenDo task
|> CT.finallyDo unlockResource
instead of
callInsideLock : ConcurrentTask e a -> ConcurrentTask e b
callInsideLock task =
lockResource
|> CT.andThenDo (task |> CT.onError (\e -> CT.andThenDo (CT.fail e) unlockResource))
|> CT.andThenDo unlockResource
Are you interested in adding this to elm-concurrent-task? I would open a PR if so.
The text was updated successfully, but these errors were encountered:
Similar to Javascripts try-catch-finally statement. For example, I'm using
finallyDo
to make sureunlockResource
gets called in both, the success and failure case:instead of
Are you interested in adding this to elm-concurrent-task? I would open a PR if so.
The text was updated successfully, but these errors were encountered: