cqrs

cqrs for javascript

API DOC

Install

npm install cqrs --save

Test

npm test

Use

var Domain = require("cqrs").Domain;
var Actor = require("cqrs").Actor;
var domain = new Domain(options);  // create a cqrs domain
class User extends Actor{

    _when(event){
        switch(event.name){
            case "changeName":
                this._data.name = event.name;
            break;
        }
    }

    changeName(name){
        this._apply("changeName",name);
    }

}
domain.register(User);
domain.on("User.changeName",function(event){
    // ......
})
domain.get("User",userId,function(err,actor){

});

// or

domain.get("User",userId).then(function(actor){
    actor.changeName("leo giese");
});

Advanced Usage

please waiting ...

  • Actor listen domain'event, and handle.
  • Saga usage.
  • Multiple domain.

LICENSE

MIT