{"action":"created","issue":{"url":"https://api.github.com/repos/hanami/events/issues/65","repository_url":"https://api.github.com/repos/hanami/events","labels_url":"https://api.github.com/repos/hanami/events/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/hanami/events/issues/65/comments","events_url":"https://api.github.com/repos/hanami/events/issues/65/events","html_url":"https://github.com/hanami/events/pull/65","id":269418269,"number":65,"title":"[FIX #64] Introduce typed event attributes","user":{"login":"smakagon","id":71746,"avatar_url":"https://avatars1.githubusercontent.com/u/71746?v=4","gravatar_id":"","url":"https://api.github.com/users/smakagon","html_url":"https://github.com/smakagon","followers_url":"https://api.github.com/users/smakagon/followers","following_url":"https://api.github.com/users/smakagon/following{/other_user}","gists_url":"https://api.github.com/users/smakagon/gists{/gist_id}","starred_url":"https://api.github.com/users/smakagon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smakagon/subscriptions","organizations_url":"https://api.github.com/users/smakagon/orgs","repos_url":"https://api.github.com/users/smakagon/repos","events_url":"https://api.github.com/users/smakagon/events{/privacy}","received_events_url":"https://api.github.com/users/smakagon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-10-29T17:34:25Z","updated_at":"2018-02-05T18:46:19Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/hanami/events/pulls/65","html_url":"https://github.com/hanami/events/pull/65","diff_url":"https://github.com/hanami/events/pull/65.diff","patch_url":"https://github.com/hanami/events/pull/65.patch"},"body":"This PR adds typed attributes to events using [dry-struct](http://dry-rb.org/gems/dry-struct/).\r\n\r\nExample of event definition:\r\n\r\n```ruby\r\nclass UserCreated < Hanami::Event::Type\r\n  event_name 'user.created'\r\n\r\n  attribute :id, Hanami::Types::UUID\r\n  attribute :name, Hanami::Types::String\r\nend\r\n```\r\n\r\nWe can instantiate and broadcast event now:\r\n\r\n```ruby\r\nuser_created = UserCreated.new(id: \"f1306260-6268-4a19-80dd-54ad1ac82039\", name: \"Sergii\")\r\nevent_bus.broadcast(user_created)\r\n```\r\n\r\nSubscriber will receive object of `UserCreated` event:\r\n\r\n```ruby\r\nevent_bus.subscribe('user.*') do |event|\r\n  event # => <UserCreated id=\"f1306260-6268-4a19-80dd-54ad1ac82039\" name=\"Sergii\">\r\nend\r\n```\r\n\r\nPS: @davydovanton I have a question regarding naming. I included `Event` to `Hanami::Event` namespace, I'm not sure if it's the best way. As well as use of `Hanami::Types` to define attribute types for an event. Probably we should discuss it too."},"comment":{"url":"https://api.github.com/repos/hanami/events/issues/comments/363181500","html_url":"https://github.com/hanami/events/pull/65#issuecomment-363181500","issue_url":"https://api.github.com/repos/hanami/events/issues/65","id":363181500,"user":{"login":"smakagon","id":71746,"avatar_url":"https://avatars1.githubusercontent.com/u/71746?v=4","gravatar_id":"","url":"https://api.github.com/users/smakagon","html_url":"https://github.com/smakagon","followers_url":"https://api.github.com/users/smakagon/followers","following_url":"https://api.github.com/users/smakagon/following{/other_user}","gists_url":"https://api.github.com/users/smakagon/gists{/gist_id}","starred_url":"https://api.github.com/users/smakagon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smakagon/subscriptions","organizations_url":"https://api.github.com/users/smakagon/orgs","repos_url":"https://api.github.com/users/smakagon/repos","events_url":"https://api.github.com/users/smakagon/events{/privacy}","received_events_url":"https://api.github.com/users/smakagon/received_events","type":"User","site_admin":false},"created_at":"2018-02-05T18:46:19Z","updated_at":"2018-02-05T18:46:19Z","author_association":"COLLABORATOR","body":"@davydovanton I'll update this PR soon, sorry for the delay."}}
{"actor":{"display_login":"smakagon"}}