{"action":"created","issue":{"url":"https://api.github.com/repos/andris9/smtp-server/issues/36","labels_url":"https://api.github.com/repos/andris9/smtp-server/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/andris9/smtp-server/issues/36/comments","events_url":"https://api.github.com/repos/andris9/smtp-server/issues/36/events","html_url":"https://github.com/andris9/smtp-server/issues/36","id":127112689,"number":36,"title":"[Feature Request]: smtp-server should emit custom events","user":{"login":"CHIEFnChowCombo","id":3282305,"avatar_url":"https://avatars.githubusercontent.com/u/3282305?v=3","gravatar_id":"","url":"https://api.github.com/users/CHIEFnChowCombo","html_url":"https://github.com/CHIEFnChowCombo","followers_url":"https://api.github.com/users/CHIEFnChowCombo/followers","following_url":"https://api.github.com/users/CHIEFnChowCombo/following{/other_user}","gists_url":"https://api.github.com/users/CHIEFnChowCombo/gists{/gist_id}","starred_url":"https://api.github.com/users/CHIEFnChowCombo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CHIEFnChowCombo/subscriptions","organizations_url":"https://api.github.com/users/CHIEFnChowCombo/orgs","repos_url":"https://api.github.com/users/CHIEFnChowCombo/repos","events_url":"https://api.github.com/users/CHIEFnChowCombo/events{/privacy}","received_events_url":"https://api.github.com/users/CHIEFnChowCombo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-17T18:09:01Z","updated_at":"2016-01-17T23:18:06Z","closed_at":"2016-01-17T23:18:06Z","body":"It would be super useful if I could subscribe to specific events from the server, instead of having to specify callbacks.   As an example, currently, when I want to handle the receipt of message data, I need to pass in an `onData` handler, which winds up creating more tightly coupled code, and restricts the patterns I can use when implementing this modules.  I'd like to be able to register listeners on these events instead, like so:\r\n\r\n```javascript\r\n// some-program.js\r\nvar mailRelayServer = require(\"./my-server\"); // is an SMTPServer instance\r\n\r\nrelayServer.on('connection', connectionHandler);\r\nrelayServer.on('message', messageHandler1);\r\nrelayServer.on('message', messageHandler2);\r\n```\r\n\r\nObviously, there are ways to do what I want without altering this source code, but the utilities gained from what I'm doing on top of this module would potentially be very useful inside this module, and I hate to expand the footprint of the npm world without good reason.\r\n\r\nIf this is something you've considered, but haven't wanted to implement due to complicating the api, I totally understand.  On the other hand, if it's just a time issue, I'd be happy to submit a PR if the idea is something you'd like to implement.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/andris9/smtp-server/issues/comments/172394656","html_url":"https://github.com/andris9/smtp-server/issues/36#issuecomment-172394656","issue_url":"https://api.github.com/repos/andris9/smtp-server/issues/36","id":172394656,"user":{"login":"CHIEFnChowCombo","id":3282305,"avatar_url":"https://avatars.githubusercontent.com/u/3282305?v=3","gravatar_id":"","url":"https://api.github.com/users/CHIEFnChowCombo","html_url":"https://github.com/CHIEFnChowCombo","followers_url":"https://api.github.com/users/CHIEFnChowCombo/followers","following_url":"https://api.github.com/users/CHIEFnChowCombo/following{/other_user}","gists_url":"https://api.github.com/users/CHIEFnChowCombo/gists{/gist_id}","starred_url":"https://api.github.com/users/CHIEFnChowCombo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CHIEFnChowCombo/subscriptions","organizations_url":"https://api.github.com/users/CHIEFnChowCombo/orgs","repos_url":"https://api.github.com/users/CHIEFnChowCombo/repos","events_url":"https://api.github.com/users/CHIEFnChowCombo/events{/privacy}","received_events_url":"https://api.github.com/users/CHIEFnChowCombo/received_events","type":"User","site_admin":false},"created_at":"2016-01-17T23:18:06Z","updated_at":"2016-01-17T23:18:06Z","body":"That's the approach i've been taking. No real problem with it, just figured I'd check to see if integrating it was something you felt would provide value to your package. It's why I mentioned the bit about \"complicating the api\".  It's not too hard to see what you meant by \"messy\" either. :-)\r\n"}}