Skip to content
/ ShortBus Public
forked from mhinze/ShortBus

Synchronous mediator with low-friction API

License

Notifications You must be signed in to change notification settings

dvins/ShortBus

 
 

Repository files navigation

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 Answer 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.AddAllTypesOf(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.

About

Synchronous mediator with low-friction API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 98.6%
  • Shell 1.4%