{"action":"created","issue":{"url":"https://api.github.com/repos/aurelia/event-aggregator/issues/10","labels_url":"https://api.github.com/repos/aurelia/event-aggregator/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/event-aggregator/issues/10/comments","events_url":"https://api.github.com/repos/aurelia/event-aggregator/issues/10/events","html_url":"https://github.com/aurelia/event-aggregator/issues/10","id":96621197,"number":10,"title":"subscribe should return subscriptionInfo object with an unsubscribe/cancel function","user":{"login":"Tlvenn","id":3340262,"avatar_url":"https://avatars.githubusercontent.com/u/3340262?v=3","gravatar_id":"","url":"https://api.github.com/users/Tlvenn","html_url":"https://github.com/Tlvenn","followers_url":"https://api.github.com/users/Tlvenn/followers","following_url":"https://api.github.com/users/Tlvenn/following{/other_user}","gists_url":"https://api.github.com/users/Tlvenn/gists{/gist_id}","starred_url":"https://api.github.com/users/Tlvenn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tlvenn/subscriptions","organizations_url":"https://api.github.com/users/Tlvenn/orgs","repos_url":"https://api.github.com/users/Tlvenn/repos","events_url":"https://api.github.com/users/Tlvenn/events{/privacy}","received_events_url":"https://api.github.com/users/Tlvenn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-07-22T17:23:33Z","updated_at":"2015-09-10T03:54:22Z","closed_at":"2015-09-09T21:44:06Z","body":"The api right now around how to  un subscribe is not really obvious and I see many people in Gitter asking how to do it which lead to something like this:\r\n\r\n```\r\nvar subscribe = ea.subscribe(''test\"); // Subscribe\r\nsubscribe(); // Unsubscribe\r\n```\r\n\r\nWhich is really weird when you look back at the code and does not reflect at all what is really going on.\r\n\r\nIdeally, the Event Aggregator should return a subscription object such as:\r\n\r\n```\r\n{\r\n  channel: 'test',\r\n  subscribedAt: dateProperty,\r\n  unsubscribe: function() {...}\r\n}\r\n```\r\n\r\nSo people can do:\r\n\r\n```\r\nvar sub = ea.subscribe(''test\"); // Subscribe\r\nsub.unsubscribe(); // Unsubscribe\r\n```\r\nWhat do you think ?"},"comment":{"url":"https://api.github.com/repos/aurelia/event-aggregator/issues/comments/139109228","html_url":"https://github.com/aurelia/event-aggregator/issues/10#issuecomment-139109228","issue_url":"https://api.github.com/repos/aurelia/event-aggregator/issues/10","id":139109228,"user":{"login":"Tlvenn","id":3340262,"avatar_url":"https://avatars.githubusercontent.com/u/3340262?v=3","gravatar_id":"","url":"https://api.github.com/users/Tlvenn","html_url":"https://github.com/Tlvenn","followers_url":"https://api.github.com/users/Tlvenn/followers","following_url":"https://api.github.com/users/Tlvenn/following{/other_user}","gists_url":"https://api.github.com/users/Tlvenn/gists{/gist_id}","starred_url":"https://api.github.com/users/Tlvenn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tlvenn/subscriptions","organizations_url":"https://api.github.com/users/Tlvenn/orgs","repos_url":"https://api.github.com/users/Tlvenn/repos","events_url":"https://api.github.com/users/Tlvenn/events{/privacy}","received_events_url":"https://api.github.com/users/Tlvenn/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T03:54:22Z","updated_at":"2015-09-10T03:54:22Z","body":"And what is the reasoning behind not trying to make the API clearer and more readable ? Pretty much all pubsub system and even Observable follow the same pattern of returning a subscription you can call dispose() or unsubscribe() on.\r\n\r\nAs i outlined above, beside being a pretty bad design choice imho, it's confusing as hell for any people new to Aurelia as it is absolutely counter intuitive and against everything they are used to."}}