Code Monkey home page Code Monkey logo

Comments (5)

adrai avatar adrai commented on July 30, 2024

Sorry for not answering in a more complete way... have not that much time right now...

The first question I had when reading quickly what you described: Aren’t you denormalizing the events? i.e. with cqrs-eventdenormalizer?

A basic example here: https://github.com/adrai/cqrs-sample

Sorry, again.

from node-cqrs-domain.

stefanomiccoli avatar stefanomiccoli commented on July 30, 2024

ah, no we are not using cqrs-eventdenormalizer.
Indeed, since our frontend was not able to handle async notifications (e.g. websockets as in your cqrs-sample) we did a nasty workaround, by hooking to the command callback of the domain.handle() call, manually generate our pseudo-viewmodel form the returned aggregate, store it in our read db (just another mongo collection) and return it in the response for the PATCH http request. I still feel a bit guilty when I think about this, but just say it was recorded as technical debt.

Now, thanks for the hint and I will dig into the docs of cqrs-eventdenormalizer and scratch my head how it could fit in our current setup. Of course any further help when time allows it would be more than welcome!

from node-cqrs-domain.

adrai avatar adrai commented on July 30, 2024

you don’t need any websocket or handling of events in the client...
Just fetch the denormalized data, like here: https://github.com/adrai/cqrs-sample/blob/master/host/app/routes.js

from node-cqrs-domain.

stefanomiccoli avatar stefanomiccoli commented on July 30, 2024

Of course, no need for that when handling queries (basically GET requests).

But when it comes to commands (PUT, PATCH, DELETE) I can see only 2 possibilities given the current limitation of our UI/UX which involves providing feedback to the user in the form of the updated resource:

  • synchronous, the response of http requests for commands containing the updated info (current workaround)
  • asynchronous, domain handle commands and emit events, denormalizer handle event and emit notifications, but in this case, in order to send the info to the frontend a websocket or polling needs to be in place, no?

fetcing the denormalized data in the callback of domain.handle would not ensure (and most likely not work) the updated data cos i have no clue when such async task will end

correct?

from node-cqrs-domain.

adrai avatar adrai commented on July 30, 2024

It depends... but if you want to go full sync... you could:
create a POST request (or similar) containing the command, in the route handle, pass the command to the domain (via bus or whatever), you could also use evented-command to wait for the event to emit: https://github.com/adrai/node-evented-command#send-commands and finally respond to the POST request with the received event in the payload.

from node-cqrs-domain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.