{"action":"opened","issue":{"url":"https://api.github.com/repos/zenparsing/esparse/issues/36","labels_url":"https://api.github.com/repos/zenparsing/esparse/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/zenparsing/esparse/issues/36/comments","events_url":"https://api.github.com/repos/zenparsing/esparse/issues/36/events","html_url":"https://github.com/zenparsing/esparse/issues/36","id":58249542,"number":36,"title":"Async generators:  what happens when you cancel an observer?","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":0,"created_at":"2015-02-19T18:37:38Z","updated_at":"2015-02-19T18:37:38Z","closed_at":null,"body":"Currently, when we cancel observation on an async generator, it will force the generator back into non-flowing mode.  This is at odds with the way that Observable currently works.  When you cancel a subscription to an observable, it will invoke the \"cleanup\" functionality that the observable has defined.\r\n\r\nFor the Observable API, calling observe \"opens\" the stream and calling the cancel function \"closes\" the stream.  I don't see how we can align that with async generators, however.  For generator functions, the \"stream\" is opened when you call the function itself. \r\n\r\n```js\r\nasync function* agf() {\r\n    yield 1;\r\n    yield 2;\r\n    yield 3;\r\n}\r\n\r\nlet x = agf(),\r\n    a = [],\r\n    b = [];\r\n\r\nx.observe({ next: (::a.push) });\r\nx.observe({ next: (::b.push) });\r\n\r\n// a -> [1, 2, 3] ?\r\n// b -> [1, 2, 3] ?\r\n\r\n```"}}