Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.24 KB

README.md

File metadata and controls

54 lines (39 loc) · 1.24 KB

ShortBus

ShortBus is a synchronous mediator with low-friction API

Command

public class DoSomething : ICommand { }

public class DoesSomething : ICommandHandler<DoSomething> {
	public void Handle(DoSomething command) {
	   // does something
	}
}

_mediator.Send(new DoSomething());

Query

public class AskAQuestion : IQuery<Answer> { }

public class Answerer : IQueryHandler<AskAQuestion, Answer> {
    public void Handle(AskAQuestion query) {			
		return answer;
	}
}

var answer = _mediator.Request(new AskAQuestion());

StructureMap

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.ConnectImplementationsToTypesClosing((typeof (IQueryHandler<,>)));
    s.AddAllTypesOf(typeof (ICommandHandler<>));
}));	

Synchronous

ShortBus is synchronous.

Low-friction API

No type parameter noise.

What for?

  • Query objects
  • Enables subcutaneous testing
  • Business concepts as first class citizens

In Production

ShortBus is in production powering the server API for a major ecommerce mobile application.