ShortBus is a synchronous mediator with low-friction API
public class DoSomething : ICommand { }
public class DoesSomething : ICommandHandler<DoSomething> {
public void Handle(DoSomething command) {
// does something
}
}
_mediator.Send(new DoSomething());
public class AskAQuestion : IQuery<Answer> { }
public class Answerer : IQueryHandler<AskAQuestion, Answer> {
public Answer Handle(AskAQuestion query) {
return answer;
}
}
var answer = _mediator.Request(new AskAQuestion());
ShortBus depends on StructureMap and it requires that you register handlers:
ObjectFactory.Initialize(i => i.Scan(s =>
{
s.AssemblyContainingType<IMediator>();
s.TheCallingAssembly();
s.WithDefaultConventions();
s.AddAllTypesOf(typeof (IQueryHandler<,>));
s.AddAllTypesOf(typeof (ICommandHandler<>));
}));
ShortBus is synchronous.
No type parameter noise.
- Query objects
- Enables subcutaneous testing
- Business concepts as first class citizens
ShortBus is in production powering the server API for a major ecommerce mobile application.