{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/6575","repository_url":"https://api.github.com/repos/meteor/meteor","labels_url":"https://api.github.com/repos/meteor/meteor/issues/6575/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/6575/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/6575/events","html_url":"https://github.com/meteor/meteor/issues/6575","id":142951213,"number":6575,"title":"Feature request: EventEmitter that emits same events on client and server.","user":{"login":"AlexFrazer","id":1350392,"avatar_url":"https://avatars.githubusercontent.com/u/1350392?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexFrazer","html_url":"https://github.com/AlexFrazer","followers_url":"https://api.github.com/users/AlexFrazer/followers","following_url":"https://api.github.com/users/AlexFrazer/following{/other_user}","gists_url":"https://api.github.com/users/AlexFrazer/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexFrazer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexFrazer/subscriptions","organizations_url":"https://api.github.com/users/AlexFrazer/orgs","repos_url":"https://api.github.com/users/AlexFrazer/repos","events_url":"https://api.github.com/users/AlexFrazer/events{/privacy}","received_events_url":"https://api.github.com/users/AlexFrazer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-23T12:49:55Z","updated_at":"2016-04-05T23:07:51Z","closed_at":null,"body":"The use case for this is if you have some execution without persistent data (eg, non-mongo backed) that occurs on both client and server. Something like this could be in common code.\r\n```\r\nimport {EventEmitter} from 'events';\r\n\r\nexport class Download extends EventEmitter {\r\n  constructor() {\r\n    super(...arguments);\r\n  }\r\n}\r\n```\r\n\r\nIt would be nice if it could emit events on both client and server and respond to them. Eg, if you had a meteor method:\r\n\r\n```\r\nMeteor.methods({\r\n  'connect': async function (download) {\r\n    this.emit('started');\r\n    await download.run();\r\n  }\r\n});\r\n```\r\n\r\nThen the client could respond to the \"started\" event because it receives it as well"},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/206027291","html_url":"https://github.com/meteor/meteor/issues/6575#issuecomment-206027291","issue_url":"https://api.github.com/repos/meteor/meteor/issues/6575","id":206027291,"user":{"login":"benjamn","id":5750,"avatar_url":"https://avatars.githubusercontent.com/u/5750?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamn","html_url":"https://github.com/benjamn","followers_url":"https://api.github.com/users/benjamn/followers","following_url":"https://api.github.com/users/benjamn/following{/other_user}","gists_url":"https://api.github.com/users/benjamn/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamn/subscriptions","organizations_url":"https://api.github.com/users/benjamn/orgs","repos_url":"https://api.github.com/users/benjamn/repos","events_url":"https://api.github.com/users/benjamn/events{/privacy}","received_events_url":"https://api.github.com/users/benjamn/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T23:07:51Z","updated_at":"2016-04-05T23:07:51Z","body":"`raix:eventemitter` looks awesome for this!"}}