{"action":"created","issue":{"url":"https://api.github.com/repos/mostjs-community/most-proxy/issues/4","repository_url":"https://api.github.com/repos/mostjs-community/most-proxy","labels_url":"https://api.github.com/repos/mostjs-community/most-proxy/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/mostjs-community/most-proxy/issues/4/comments","events_url":"https://api.github.com/repos/mostjs-community/most-proxy/issues/4/events","html_url":"https://github.com/mostjs-community/most-proxy/issues/4","id":170987578,"number":4,"title":"Bug: proxy continues emitting events to disposed observer","user":{"login":"axefrog","id":298883,"avatar_url":"https://avatars.githubusercontent.com/u/298883?v=3","gravatar_id":"","url":"https://api.github.com/users/axefrog","html_url":"https://github.com/axefrog","followers_url":"https://api.github.com/users/axefrog/followers","following_url":"https://api.github.com/users/axefrog/following{/other_user}","gists_url":"https://api.github.com/users/axefrog/gists{/gist_id}","starred_url":"https://api.github.com/users/axefrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axefrog/subscriptions","organizations_url":"https://api.github.com/users/axefrog/orgs","repos_url":"https://api.github.com/users/axefrog/repos","events_url":"https://api.github.com/users/axefrog/events{/privacy}","received_events_url":"https://api.github.com/users/axefrog/received_events","type":"User","site_admin":false},"labels":[{"id":350970711,"url":"https://api.github.com/repos/mostjs-community/most-proxy/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-08-13T01:59:45Z","updated_at":"2016-11-12T07:38:10Z","closed_at":"2016-11-12T07:35:46Z","body":"I have a small bit of code in which I'm using a proxy:\n\n``` js\nfunction proxy(initial) {\n  const {attach, stream} = makeProxy();\n  return [stream.startWith(initial), attach];\n}\n\nexport default function flatScan(f, initial) {\n  return stream => {\n    const [proxyState$, fulfill] = proxy(initial);\n    const state$ = most.just(proxyState$).join(); // prevent proxy disposal bug\n    const initialize = (x, state) => f(state, x, state$);\n    const nextState$ = sample(initialize, stream, state$)\n      .join()\n      .thru(fn$ => sample((fn, state) => fn(state), fn$, state$))\n      .startWith(initial)\n      .multicast();\n    fulfill(nextState$);\n    return state$;\n  };\n}\n```\n\nNotice the commented line where I'm wrapping the proxy stream in another stream and then flattening it again. If I don't do this, and a second observer attaches to the proxy before the previous observer has disposed itself, then the original observer will still try to call dispose as it should, but the proxy will continue emitting events to that observer's sink, even after disposal. Somehow wrapping the proxy in another dummy operator solves the problem.\n\nIf you need an active use case in order to figure this out, let me know and I'll help you set up a working copy of my project so you can see it happening.\n"},"comment":{"url":"https://api.github.com/repos/mostjs-community/most-proxy/issues/comments/260107560","html_url":"https://github.com/mostjs-community/most-proxy/issues/4#issuecomment-260107560","issue_url":"https://api.github.com/repos/mostjs-community/most-proxy/issues/4","id":260107560,"user":{"login":"TylorS","id":6282473,"avatar_url":"https://avatars.githubusercontent.com/u/6282473?v=3","gravatar_id":"","url":"https://api.github.com/users/TylorS","html_url":"https://github.com/TylorS","followers_url":"https://api.github.com/users/TylorS/followers","following_url":"https://api.github.com/users/TylorS/following{/other_user}","gists_url":"https://api.github.com/users/TylorS/gists{/gist_id}","starred_url":"https://api.github.com/users/TylorS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TylorS/subscriptions","organizations_url":"https://api.github.com/users/TylorS/orgs","repos_url":"https://api.github.com/users/TylorS/repos","events_url":"https://api.github.com/users/TylorS/events{/privacy}","received_events_url":"https://api.github.com/users/TylorS/received_events","type":"User","site_admin":false},"created_at":"2016-11-12T07:38:10Z","updated_at":"2016-11-12T07:38:10Z","body":"This should be fixed with version 3.2.0.\r\n\r\nI have a test for this now, modified from the webpackbin @whitecolor made, thanks for that again @whitecolor. That test is [here](https://github.com/mostjs-community/most-proxy/blob/master/test/index.ts#L25)"}}
{"actor":{"display_login":"TylorS"}}