{"action":"created","issue":{"url":"https://api.github.com/repos/cujojs/most/issues/360","repository_url":"https://api.github.com/repos/cujojs/most","labels_url":"https://api.github.com/repos/cujojs/most/issues/360/labels{/name}","comments_url":"https://api.github.com/repos/cujojs/most/issues/360/comments","events_url":"https://api.github.com/repos/cujojs/most/issues/360/events","html_url":"https://github.com/cujojs/most/issues/360","id":192452767,"number":360,"title":"calling unsubscribe in React not unsubscribe observer immediately","user":{"login":"jcouyang","id":1235045,"avatar_url":"https://avatars.githubusercontent.com/u/1235045?v=3","gravatar_id":"","url":"https://api.github.com/users/jcouyang","html_url":"https://github.com/jcouyang","followers_url":"https://api.github.com/users/jcouyang/followers","following_url":"https://api.github.com/users/jcouyang/following{/other_user}","gists_url":"https://api.github.com/users/jcouyang/gists{/gist_id}","starred_url":"https://api.github.com/users/jcouyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcouyang/subscriptions","organizations_url":"https://api.github.com/users/jcouyang/orgs","repos_url":"https://api.github.com/users/jcouyang/repos","events_url":"https://api.github.com/users/jcouyang/events{/privacy}","received_events_url":"https://api.github.com/users/jcouyang/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-30T01:43:33Z","updated_at":"2016-12-05T00:34:54Z","closed_at":"2016-12-05T00:34:54Z","body":"i'm working on a lib [react-most](https://github.com/reactive-react/react-most) to make most works with React, a issue bug me recently, what i'm expecting was that when i call unsubscribe imperatively in `componentWillUnmount()`, it should immediately \"unsubscribe\" the observer\r\n```js\r\ncomponentWillUnmount(){\r\n  this.subscriptions.unsubscribe()\r\n}\r\n```\r\nbut after the component unmount, observer still get called. this will cause a unmounted component call it's `setState`.\r\n\r\nin [componentDidMount](https://github.com/reactive-react/react-most/blob/master/lib/react-most.js#L57), i simply merge all streams and subscribe to setState. [L59](https://github.com/reactive-react/react-most/blob/master/lib/react-most.js#L59) is currently my work around to this issue\r\n\r\nin [Todomvc](https://github.com/reactive-react/react-most/blob/master/examples/todomvc) example, the issue will happen when\r\n- delete for example todo item with id 0\r\n- there will be 2 streams react on this change, `mainSection`, and `todoItem`\r\n1. `mainSection` will `setState` to remove item 0 in todo array,\r\n2.  React will call todoItem's `componentWillUnmount`(which will call unsubscribe) then unmount the component\r\n3. todoItem 0 itself will also react on this event, even step 2 already call unmount and `subscriptions.unsubscribe`, observer(setState) still been called on this unmounted component.  what i expected is todoItem 0 should stop calling it's observer in sync when unsubscirbe is imperatively called."},"comment":{"url":"https://api.github.com/repos/cujojs/most/issues/comments/264744639","html_url":"https://github.com/cujojs/most/issues/360#issuecomment-264744639","issue_url":"https://api.github.com/repos/cujojs/most/issues/360","id":264744639,"user":{"login":"briancavalier","id":90518,"avatar_url":"https://avatars.githubusercontent.com/u/90518?v=3","gravatar_id":"","url":"https://api.github.com/users/briancavalier","html_url":"https://github.com/briancavalier","followers_url":"https://api.github.com/users/briancavalier/followers","following_url":"https://api.github.com/users/briancavalier/following{/other_user}","gists_url":"https://api.github.com/users/briancavalier/gists{/gist_id}","starred_url":"https://api.github.com/users/briancavalier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briancavalier/subscriptions","organizations_url":"https://api.github.com/users/briancavalier/orgs","repos_url":"https://api.github.com/users/briancavalier/repos","events_url":"https://api.github.com/users/briancavalier/events{/privacy}","received_events_url":"https://api.github.com/users/briancavalier/received_events","type":"User","site_admin":false},"created_at":"2016-12-05T00:34:54Z","updated_at":"2016-12-05T00:34:54Z","body":"Closed by #361 "}}
{"actor":{"display_login":"briancavalier"}}