{"action":"created","issue":{"url":"https://api.github.com/repos/zenparsing/es-observable/issues/48","labels_url":"https://api.github.com/repos/zenparsing/es-observable/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/zenparsing/es-observable/issues/48/comments","events_url":"https://api.github.com/repos/zenparsing/es-observable/issues/48/events","html_url":"https://github.com/zenparsing/es-observable/issues/48","id":97550237,"number":48,"title":"Discussion: Subscribe returns a cancellation function","user":{"login":"zenparsing","id":5995084,"avatar_url":"https://avatars.githubusercontent.com/u/5995084?v=3","gravatar_id":"","url":"https://api.github.com/users/zenparsing","html_url":"https://github.com/zenparsing","followers_url":"https://api.github.com/users/zenparsing/followers","following_url":"https://api.github.com/users/zenparsing/following{/other_user}","gists_url":"https://api.github.com/users/zenparsing/gists{/gist_id}","starred_url":"https://api.github.com/users/zenparsing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zenparsing/subscriptions","organizations_url":"https://api.github.com/users/zenparsing/orgs","repos_url":"https://api.github.com/users/zenparsing/repos","events_url":"https://api.github.com/users/zenparsing/events{/privacy}","received_events_url":"https://api.github.com/users/zenparsing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":66,"created_at":"2015-07-27T20:43:08Z","updated_at":"2015-10-07T14:04:07Z","closed_at":null,"body":"In the current version, `subscribe` returns a cancellation function.  Previously, `subscribe` returned a \"subscription\" object with an \"unsubscribe\" method.\r\n\r\nRationale:\r\n\r\n1. Since working on this project, I've typed in \"subscription.unsubscribe\" many, many times.  It's ugly and a real pain.\r\n1. We currently haven't identified any essential capabilities that need to be returned from \"subscribe\" other than the cancellation function.  It's nice to avoid useless wrapper objects.\r\n1. Any additional capabilities returned from \"subscribe\" are probably going to be POLA-problematic.\r\n1. The return types of \"subscribe\" and the subscriber function align nicely.\r\n\r\nRegarding 4:\r\n\r\nWe frequently want to \"chain\" observables like this:\r\n\r\n```js\r\nfunction x(observable) {\r\n    return new Observable(observer => observable.subscribe({\r\n        // ... whatever\r\n    });\r\n}\r\n```\r\n\r\nIf \"subscribe\" returns something other than a `() => void` function, then we have to bake-in some messy overloading in order to make that chaining nice and pleasant.  RxJS makes use of overloading in several places (also \"subscribe\") which I would like to avoid.\r\n\r\nThoughts?\r\n"},"comment":{"url":"https://api.github.com/repos/zenparsing/es-observable/issues/comments/146204749","html_url":"https://github.com/zenparsing/es-observable/issues/48#issuecomment-146204749","issue_url":"https://api.github.com/repos/zenparsing/es-observable/issues/48","id":146204749,"user":{"login":"benjamingr","id":1315533,"avatar_url":"https://avatars.githubusercontent.com/u/1315533?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamingr","html_url":"https://github.com/benjamingr","followers_url":"https://api.github.com/users/benjamingr/followers","following_url":"https://api.github.com/users/benjamingr/following{/other_user}","gists_url":"https://api.github.com/users/benjamingr/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamingr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamingr/subscriptions","organizations_url":"https://api.github.com/users/benjamingr/orgs","repos_url":"https://api.github.com/users/benjamingr/repos","events_url":"https://api.github.com/users/benjamingr/events{/privacy}","received_events_url":"https://api.github.com/users/benjamingr/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T14:04:07Z","updated_at":"2015-10-07T14:04:07Z","body":"> I'm 100% sure that leaking resolve and reject from a promise constructor is considered bad practice by the community as a whole.\r\n\r\nWhile _I_ think leaking resolve and reject from the promise constructor is considered bad practice _in most cases_. Two things to consider are:\r\n\r\n - People do it all the time, I see it in StackOverflow questions at least once a weak - so I doubt the community is against it. \r\n - There are several legitimate use cases for leaking resolve and reject, and I had to \"leak\" them several times in my code (although I'm well aware of how to use promises).\r\n\r\nThe observable analogy is leaking an observer though - not a subscription, which exists in most code bases I've read that use Rx (through subjects). Although that might go away once native APIs start returning observables or automatic observable conversion methods start being broadly used enough. \r\n"}}