mhinze / ShortBus

In-process mediator with low-friction API
MIT License
210 stars 41 forks source link

Following instructions in readme is a compilation error #32

Open togakangaroo opened 10 years ago

togakangaroo commented 10 years ago

I tried to create a simple command handler as in the example on the README but this is giving me a compilation error due to Handle not returning anything.

    public class UserRegistered : ICommandHandler<RegisterUser>
    {
        public void Handle(RegisterUser user) {
        }
    }

Versioning:

Id                             Version              Description/Release Notes
--                             -------              -------------------------
ShortBus                       3.0.46-beta          ShortBus is an in-process mediator with low-friction API
ShortBus.Markers               3.0.43-beta          ShortBus is an in-process mediator with low-friction API
ShortBus.StructureMap          3.0.48-beta          ShortBus is an in-process mediator with low-friction API
structuremap                   3.0.5.130            StructureMap is a Dependency Injection / Inversion of Control tool for .Net that can be used to improve the architectural qualities of an object oriented syst...
xunit                          1.9.2                xUnit.net is a developer testing framework, built to support Test Driven Development, with a design goal of extreme simplicity and alignment with framework fe...
mxmissile commented 10 years ago

@togakangaroo Unless I dont understand the question, Commands don't return anything, as you can see Handle is void. Use a Query if you need to return something.

getuliojr commented 9 years ago

I am also confused. Commands should not return anything, but if a command is to save a data do the database and get a new ID, how is this new ID supposed to get back to the client if a command can´t return a value ?

mxmissile commented 9 years ago

Use IQuery (or in the latest IRequest?) when data is needed to be returned.

var data = mediator.Request(query).Data;

https://github.com/mhinze/ShortBus/blob/master/ShortBus.Tests/Example/BasicExample.cs