Skip to content

0.17.1

Compare
Choose a tag to compare
@rofr rofr released this 25 Sep 19:51
· 149 commits to master since this release

Redesigned domain events API. See http://dev.origodb.com/docs/domain-events for details.

Some example code

//example domain event
public class CustomerCreated : IEvent
{
   public readonly int Id;
   public CustomerCreated(int id)
   {
      Id = id;
   }
}

//subscribing to events
var db = new MyModel();

//all events
db.Events.Subscribe(e => MyEventHandler(e));

//all events of a specific (or derived) type
db.Events.On<CustomerCreated>(e => Console.WriteLine(e));

//filtered events
db.Events.Subscribe(e => MyEventHandler(e), e => MyFilter(e));

//publish events
db.Events.Send(new CustomerCreated(42));

//subscribe to events through engine:
var engine = Engine.For<MyModel>();
engine.CommandExecuted += (s,e) => {
   foreach(IEvent evt in e.Events)
   {
      //process event
   }
};

//execute command which produces events
engine.Execute(new CreateCustomerCommand(42, "Batman"));