title: Dispatching CQRS messages in Node.js
body: <p>I want to do CQRS for a Node app.</p>
  
  <p>I'm not a Node person, I'm from .NET, which has an excellent library called MediatR which dispatches commands/queries to a mediator that can be used to decouple requests and handlers. So it allows very simple and elegant CQRS.</p>
  
  <p>In the Node world I found many libraries/blogs but they always include Event Sourcing too. I'm not interested in ES.</p>
  
  <p>I can model the commands and queries nicely, but then what? They need to be dispatched somewhere, in a decoupled way to avoid a mess.</p>
  
  <p>From what I know so far about the Node platform, a possible solution is to use the observer pattern (via the RxJs library), so a controller can dispatch messages (i.e. CQRS requests) to an observer, which then publishes corresponding events for subscribers (i.e. request handlers). This decouples controllers and  services in a DDD-like design. Though I'm not sure how to pass results back to the controller.</p>
  
  <p>Is this how other people are doing it? Is there a better way in Node?</p>