Closed bartelink closed 2 years ago
For context, some other examples snipped from a codebase I'm working on:
member x.TransactAsyncWithVersionAndPostState(decide, mapResult) =
x.TransactEx((fun c -> decide c.Version c.State), fun r c -> mapResult r c.State)
member x.TransactAsyncWithPostState(decide, mapResult) =
x.TransactEx((fun c -> async { let! es = decide c.State in return (), es }), fun () c -> mapResult c.State)
member x.TransactWithPostState(decide, mapResult) =
x.TransactEx((fun c -> async { let es = decide c.State in return (), es }), fun () c -> mapResult c.State)
member x.QueryWithVersion(projection) =
x.QueryEx(fun c -> c.Version, projection c.State)
While there can be a place for a DRY
let
-bound helper in atype Service
, in general it makes more sense to codify a specificTransact
orQuery
pattern common within a particular category, domain or app as an extension method onDecider
, rather than as a local helper.cc @ahjohannessen