{"action":"opened","issue":{"url":"https://api.github.com/repos/afrad/angular2-websocket/issues/5","repository_url":"https://api.github.com/repos/afrad/angular2-websocket","labels_url":"https://api.github.com/repos/afrad/angular2-websocket/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/afrad/angular2-websocket/issues/5/comments","events_url":"https://api.github.com/repos/afrad/angular2-websocket/issues/5/events","html_url":"https://github.com/afrad/angular2-websocket/issues/5","id":140167437,"number":5,"title":"Rxjs Subject misuse","user":{"login":"vladvelici","id":787566,"avatar_url":"https://avatars.githubusercontent.com/u/787566?v=3","gravatar_id":"","url":"https://api.github.com/users/vladvelici","html_url":"https://github.com/vladvelici","followers_url":"https://api.github.com/users/vladvelici/followers","following_url":"https://api.github.com/users/vladvelici/following{/other_user}","gists_url":"https://api.github.com/users/vladvelici/gists{/gist_id}","starred_url":"https://api.github.com/users/vladvelici/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladvelici/subscriptions","organizations_url":"https://api.github.com/users/vladvelici/orgs","repos_url":"https://api.github.com/users/vladvelici/repos","events_url":"https://api.github.com/users/vladvelici/events{/privacy}","received_events_url":"https://api.github.com/users/vladvelici/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-11T11:59:43Z","updated_at":"2016-03-11T11:59:43Z","closed_at":null,"body":"First of all, thanks for writing this!\r\n\r\nI have run into an issue and I don't know what would be a nice solution. Briefly: when a websocket connection fails, both onClose and onError are called, which makes sense, except for the `dataStream` subject.\r\n\r\nConsider this snippet:\r\n\r\n    var x = new Subject();\r\n    x.error(\"error message\");\r\n    // x.isCompleted === true, therefore:\r\n    x.complete(); // raises an ObjectUnsubscribedError\r\n\r\nThis is exactly what happens when an error occurs. I don't know what would be a nice solution for this, especially if you consider that you (sort of) want to abstract away reconnects in the dataStream (or at least that would be nice from my point of view).\r\n\r\nCurrently you would need to create another Subject for a new connection, and get the *clients* to resubscribe. This is OK but might need a bit of refactoring to make this obvious. Example: give the Subject as a parameter to the `onInit` callback, so it clearly represents only one connection.\r\n\r\nNow I'm just using a stripped down version that does not have that Subject, and use only the callbacks and have my own observables that also perform some application logic.\r\n\r\nI'm happy to make a PR after we discuss what would be a nice solution.\r\n\r\nAll the best,\r\nVlad\r\n"}}