Can I dispatch events within domain service? -


i have userregistry bc. has accountservice contains methods accountid registeraccount(string username, string password) , void changepassword(accountid id, string newpassword). don't have ars because domain talks external service through acl , of operations handled external service. another bc needs able act on accountregistered , accountpasswordchanged events. actually, that's whole point of context - provide interface functionality , raise specific events whenever occur.

given information, can raise events in acl service? (actually, accountservice acl) or can raise them in application layer use acl? how can raise events without aggregate roots?

for now, have following implementation:

// external system integration service. interface iexternalsystem {     string register(string name, string password); }  // acl domain service. class accountservice {     accountid register(string name, string password)     {         return accountid.fromstring(             _externalsystem.register(name, password));     } }  // application layer service. can implemented command handlers. class accountapplicationservice {     accountid register(string name, string password)     {         var id = _accountservice.register(name, password);          // line under question.         _eventdispatcher.dispatch(new accountregistered(id, name));          return id;     } } 


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -