events - How to "query" the aggregate to see if a command can be executed -


i have email draft aggregate root following commands: addtorecipient, addccrecipient, addbccrecipient, updatebodytext, uploadattachment, removeattachment , in ui want disable send button if draft not ready sent (i.e. there @ least on recipient , body has text). know i'm not allowed query aggregate 1 can tell me can or can't send email.

if apply know event sourcing , cqrs, aggregate emit emailisreadytobesent event , useremaildrafts read model pick , update ui somehow then, have check after every command , send canceling event i.e. emailisnotreadytobesent.

this feels complicated, think?

the fact email cannot sent unless there recipient , body bordering on applicative logic, because @ end of day it's more matter of fields being filled in on form complex domain invariants.

rather relying on full cross-tier round trip querying read model each time changes on screen, inject knowledge of these basic rules in ui button instantaneously re-enabled when recipient , body specified.

much aren't shocked when see client-side logic doing required field validation on form, actually. it's valid , accepted tradeoff since logic simple , universal.

note doesn't prevent having these rules in aggregate well, rejecting command wouldn't satisfy them.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -