Comments (5)
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.
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.
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.
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.
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)
- Let MongoDB generate the aggregate ID? HOT 6
- Is it possible to replace the t4-validation? HOT 5
- CQRS Question about bulk import HOT 5
- revision guard HOT 6
- [Bug] Precondition aggregate is empty HOT 2
- How to use in AWS Lambda HOT 5
- Can a command fire more than one event? HOT 3
- Access meta in command HOT 2
- How to use domainPath in unit tests HOT 7
- Context and aggregateId HOT 5
- defaultCommandHandler bug, adding "undefined" to array of evtsToDispatch HOT 1
- How to clear/init HOT 2
- Same event name in different contexts HOT 2
- default value command schema HOT 2
- Where to catch Error: Please pass a valid aggregate id! HOT 11
- Transaction with two aggregates HOT 1
- How to handle errors thrown from defineCommand / defineEvent handlers? HOT 9
- Unique field validation HOT 7
- Update deps HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-cqrs-domain.