{"action":"created","issue":{"url":"https://api.github.com/repos/efacilitation/eventric/issues/14","labels_url":"https://api.github.com/repos/efacilitation/eventric/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/efacilitation/eventric/issues/14/comments","events_url":"https://api.github.com/repos/efacilitation/eventric/issues/14/events","html_url":"https://github.com/efacilitation/eventric/issues/14","id":53519724,"number":14,"title":"Default DomainEventPayload","user":{"login":"Sandreu","id":1159585,"avatar_url":"https://avatars.githubusercontent.com/u/1159585?v=3","gravatar_id":"","url":"https://api.github.com/users/Sandreu","html_url":"https://github.com/Sandreu","followers_url":"https://api.github.com/users/Sandreu/followers","following_url":"https://api.github.com/users/Sandreu/following{/other_user}","gists_url":"https://api.github.com/users/Sandreu/gists{/gist_id}","starred_url":"https://api.github.com/users/Sandreu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sandreu/subscriptions","organizations_url":"https://api.github.com/users/Sandreu/orgs","repos_url":"https://api.github.com/users/Sandreu/repos","events_url":"https://api.github.com/users/Sandreu/events{/privacy}","received_events_url":"https://api.github.com/users/Sandreu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/efacilitation/eventric/labels/enhancement","name":"enhancement","color":"006b75"},{"url":"https://api.github.com/repos/efacilitation/eventric/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-01-06T14:29:48Z","updated_at":"2015-01-07T16:33:25Z","closed_at":null,"body":"Hello,\r\n\r\nI found while using that domain events payload definition is often copy in `this` of the event argument :\r\n\r\n``` coffee\r\nvar domainEvents = \r\n  create: (attributes) ->\r\n    @[key] = val for key, val of attributes\r\n    @\r\n  remove: ->\r\n    @\r\n  #....\r\n\r\ncontext.addDomainEvents domainEvents\r\n```\r\n\r\nI figured out that almost every domainEvent definition is quite dumb. The real brain is the aggregate.\r\n\r\nWhat do you think about put the payload into the domainEvent from the `context::emitDomainEvent` method if the domainEventClass is not defined ?\r\n\r\nTo be more restrictive it could be only if the payload is an object... or put it straight in payload if the domainEventClass is not defined.\r\n\r\nI talk about what happens [here](https://github.com/efacilitation/eventric/blob/master/src/context/context.coffee#L77)\r\n\r\nI will pull request if you agree.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/efacilitation/eventric/issues/comments/69048385","html_url":"https://github.com/efacilitation/eventric/issues/14#issuecomment-69048385","issue_url":"https://api.github.com/repos/efacilitation/eventric/issues/14","id":69048385,"user":{"login":"alexlawrence","id":1098466,"avatar_url":"https://avatars.githubusercontent.com/u/1098466?v=3","gravatar_id":"","url":"https://api.github.com/users/alexlawrence","html_url":"https://github.com/alexlawrence","followers_url":"https://api.github.com/users/alexlawrence/followers","following_url":"https://api.github.com/users/alexlawrence/following{/other_user}","gists_url":"https://api.github.com/users/alexlawrence/gists{/gist_id}","starred_url":"https://api.github.com/users/alexlawrence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexlawrence/subscriptions","organizations_url":"https://api.github.com/users/alexlawrence/orgs","repos_url":"https://api.github.com/users/alexlawrence/repos","events_url":"https://api.github.com/users/alexlawrence/events{/privacy}","received_events_url":"https://api.github.com/users/alexlawrence/received_events","type":"User","site_admin":false},"created_at":"2015-01-07T16:33:25Z","updated_at":"2015-01-07T16:33:25Z","body":"> We talked about validation rules in #6...\r\n> What I retained form this, is that the aggregate doesn't know outside world.\r\n> And a uniqueness test should be done in command handler.\r\n\r\nYeah, that wasn´t the best example. Let´s say if you want to check whether an e-mail was blacklisted or not. You would do this in the aggregate (probably via using a domain servcie to make some request). However checking that an e-mail is a string is just type validation and does not belong in the aggregate.\r\n\r\n> For example I'm building an environment where every attributes of an entity can be personalized.\r\n\r\nI don´t really understand what scenario this would be but I would recommend to question such a payload. Let´s say you have a registry of persons and details of persons can be changed. You could go along and introduce the event \"PersonChanged\" and just give some arbitrary payload. However this wouldn´t really conform to the idea of event based/sourced systems. Your events should describe what happened in a specific way (behaviour, intent). So you should have events like \"PersonNameChanged\" and \"PersonAddressChanged\". Otherwise you risk to implement a CRUD like system.\r\n\r\n> For me payload is a poor value, and this just has to be checked in aggregate...\r\n\r\nI´m not sure what you mean by poor value. The payload has actually a lot of value. :-)"}}