Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate TransactWith impl pattern #113

Merged
merged 3 commits into from
Feb 22, 2022
Merged

Conversation

bartelink
Copy link
Collaborator

@bartelink bartelink commented Feb 16, 2022

While there can be a place for a DRY let-bound helper in a type Service, in general it makes more sense to codify a specific Transact or Query pattern common within a particular category, domain or app as an extension method on Decider, rather than as a local helper.

cc @ahjohannessen

@bartelink
Copy link
Collaborator Author

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)

@bartelink bartelink merged commit 4a9a5f7 into master Feb 22, 2022
@bartelink bartelink deleted the transact-extensions branch February 22, 2022 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant