{"action":"created","issue":{"url":"https://api.github.com/repos/vuejs/vue/issues/2760","repository_url":"https://api.github.com/repos/vuejs/vue","labels_url":"https://api.github.com/repos/vuejs/vue/issues/2760/labels{/name}","comments_url":"https://api.github.com/repos/vuejs/vue/issues/2760/comments","events_url":"https://api.github.com/repos/vuejs/vue/issues/2760/events","html_url":"https://github.com/vuejs/vue/issues/2760","id":151573401,"number":2760,"title":"[Suggestion] Vue 2.0 - Replacement for $broadcast and $dispatch","user":{"login":"Nirazul","id":781476,"avatar_url":"https://avatars.githubusercontent.com/u/781476?v=3","gravatar_id":"","url":"https://api.github.com/users/Nirazul","html_url":"https://github.com/Nirazul","followers_url":"https://api.github.com/users/Nirazul/followers","following_url":"https://api.github.com/users/Nirazul/following{/other_user}","gists_url":"https://api.github.com/users/Nirazul/gists{/gist_id}","starred_url":"https://api.github.com/users/Nirazul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nirazul/subscriptions","organizations_url":"https://api.github.com/users/Nirazul/orgs","repos_url":"https://api.github.com/users/Nirazul/repos","events_url":"https://api.github.com/users/Nirazul/events{/privacy}","received_events_url":"https://api.github.com/users/Nirazul/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/vuejs/vue/labels/2.0","name":"2.0","color":"f9d0c4"},{"url":"https://api.github.com/repos/vuejs/vue/labels/discussion","name":"discussion","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-04-28T08:02:08Z","updated_at":"2016-10-01T01:10:19Z","closed_at":"2016-04-29T03:29:04Z","body":"First of all, thanks for all the great work so far. vuejs is by a great measure the most enjoyable frontend framework I've tried so far.\r\n\r\nAs for some of the changes that are scheduled for v2, I'd like to know if a replacement with a plugin is possible. \r\nOne thing i liked about events is the `events` scope where all listeners are gathered. With your suggestion for vue2 with a global event-bus, I don't see how I can replace following code:\r\n\r\n```\r\nmy comp = {\r\n    events: {\r\n        'overlay:close': function() {\r\n            /* handle event */\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nI don't miss the actual hierarchy of $broadcast and $dispatch within the component tree, but I'd really love to keep a global event bus that works together with the `events` object. If this is possible through a plugin, that would fit my needs. Maybe it could be possible to make `$emit` emit globally with an additional attribute?"},"comment":{"url":"https://api.github.com/repos/vuejs/vue/issues/comments/250883407","html_url":"https://github.com/vuejs/vue/issues/2760#issuecomment-250883407","issue_url":"https://api.github.com/repos/vuejs/vue/issues/2760","id":250883407,"user":{"login":"rhyek","id":702922,"avatar_url":"https://avatars.githubusercontent.com/u/702922?v=3","gravatar_id":"","url":"https://api.github.com/users/rhyek","html_url":"https://github.com/rhyek","followers_url":"https://api.github.com/users/rhyek/followers","following_url":"https://api.github.com/users/rhyek/following{/other_user}","gists_url":"https://api.github.com/users/rhyek/gists{/gist_id}","starred_url":"https://api.github.com/users/rhyek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhyek/subscriptions","organizations_url":"https://api.github.com/users/rhyek/orgs","repos_url":"https://api.github.com/users/rhyek/repos","events_url":"https://api.github.com/users/rhyek/events{/privacy}","received_events_url":"https://api.github.com/users/rhyek/received_events","type":"User","site_admin":false},"created_at":"2016-10-01T01:10:19Z","updated_at":"2016-10-01T01:10:19Z","body":"I think removing $dispatch was a terrible idea. This wasn't the first ui framework/library to implement the notion of bubbling actions/events up a visual tree. It's a well established idea. Why take away this functionality on the premise that \" being able to dispatch a event that causes side effects in its unknown parent tree sounds like a recipe for trouble to me\"? You need to leave this responsibility to the users. I'm sure most have the common sense to use this feature appropriately. It is not a new concept!\r\n\r\nI really can't see the benefit of this change when this library is built upon long time established web technologies/concepts such as the DOM and **DOM events** that do in fact bubble up the visual tree and have been doing so for years with no one complaining. Isn't the idea of components something that has been recently embraced thanks to the W3C proposal for web components? In my opinion, It only makes sense that Vue components behave similarly to regular DOM elements in regards to how event handling is done.\r\n\r\nThe proposed alternative to use a global event bus seems illogical to me when something more practical, effective, and easier to understand (due to it being a well established concept for years) already existed.\r\n\r\nOther proposals in this thread remind me of how EmberJS wants to do it. Passing closure actions as properties to the components down each level of the hierarchy. So tedious and unnecessary! Vuejs was the reason i wrote https://www.npmjs.com/package/ember-component-action-bubbling!\r\n\r\nAside from this, I really like your library. But seriously, I think this was a terrible change.\r\n"}}
{"actor":{"display_login":"rhyek"}}