cqrs-react-router
cqrs-react-router is a library that will help you easily set up a CQRS/event sourcing system
typescript support
cqrs-react-router is written in typescript and therefore will always support typescript
how to contribute
feel free to submit pull requests, just please provide clear notes as to what your update will change. Pull requests that cause tests to fail will not be accepted.
how to install
you will need npm. Then install this library with
npm install cqrs-react-router
cqrs
to start writing your own typescript cqrs application, you will need an application service, to which you register command handlers and views
; name = "SomeView"; // subscribers can get updates for this view stuff = 0; { var self = this; } { //do something } { } implements IAmACommandHandler commandNames = "SomeCommand"; // this handler will handle commands with these names domainService; var appService = ApplicationServiceInstance; appService;appService;
To subscriber to a view
appService;
To handle a command
appService
To validate a command from views
commandNames = COMMAND_NAME; { // getViewByName fetches view from application service this; }ApplicationServiceInstance;
router
use just like react-router, only it will inject an application service that you can subscribe to.
; <any any> { return <div> Some stuff </div> } Component<AppProps AppState> { return <Router applicationService=> <Route path="/" component=SomePage /> </Router> }
replay events!
testApplicationService;
apply events from external sources
testApplicationService;