Skip to content

Provide some transforming interface to dispatch one type as another type #6

@CzechsMix

Description

@CzechsMix

Provide some interface or API for providing a conversion from type A to type B so that when A is disptached, an instance of B will be dispatched to handlers, either in addition to or in lieu of.

Use case

// pins the types that can be assigned to outcome instead of just "object"
Either<Some.Success, Some.Error> outcome = await doWork();
_dispatcher.Dispatch(outcome) 
// wouldn't disptached Either<A, B>, but would unwrap 
// the either and dispatch the underlying value.

Some ideas

public interface IDispatchTransformer
{
  public bool AppliesTo(object obj);
  public bool ReplacesOriginal { get; }
  public object Transform(object obj);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions