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

feature(Result): add mechanism to execute an action based on the state of the previous result #586

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

daht-x
Copy link
Owner

@daht-x daht-x commented Dec 24, 2024

Pull request

Thank you very much for your contribution

Please read and follow our code of conduct and contributing guidelines.

Table of contents

  1. Description

Description

The Match method was added to execute an action based on the state of the previous result, for example:

  • Match(Action doOnFailure, Action doOnSuccess):

    public static Result<Failure, Product> Create(Guid identifier, ...)
    {
        Product product = new();
        Result<Failure, Unit> result = ProductIdentifier.Create(identifier)
            .Match(() => { ... }, () => { ... })
        ...
    }
  • Match(Action<TFailure> doOnFailure, Action<TSuccess> doOnSuccess):

    public static Result<Failure, Product> Create(Guid identifier, ...)
    {
        Product product = new();
        Result<Failure, Unit> result = ProductIdentifier.Create(identifier)
            .Match(failure => { ... }, success => product.Identifier = success)
        ...
    }

Top

@daht-x daht-x added topic: feature Indicates a relationship with a new feature or enhancement priority: medium Indicates a medium priority status: pending Indicates a pending status library: core Indicates a relationship with "Core" library labels Dec 24, 2024
@daht-x daht-x self-assigned this Dec 24, 2024
@daht-x daht-x added status: approved Indicates an approved status and removed status: pending Indicates a pending status labels Dec 24, 2024
@daht-x daht-x merged commit ab7aa6d into main Dec 24, 2024
7 checks passed
@daht-x daht-x deleted the daht-x/feature/result branch December 24, 2024 21:41
@daht-x daht-x added status: inactive Indicates an inactive status and removed status: approved Indicates an approved status labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library: core Indicates a relationship with "Core" library priority: medium Indicates a medium priority status: inactive Indicates an inactive status topic: feature Indicates a relationship with a new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant