{"action":"opened","issue":{"url":"https://api.github.com/repos/HNeukermans/ng2-signalr/issues/58","repository_url":"https://api.github.com/repos/HNeukermans/ng2-signalr","labels_url":"https://api.github.com/repos/HNeukermans/ng2-signalr/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/HNeukermans/ng2-signalr/issues/58/comments","events_url":"https://api.github.com/repos/HNeukermans/ng2-signalr/issues/58/events","html_url":"https://github.com/HNeukermans/ng2-signalr/issues/58","id":234771997,"number":58,"title":"ConnectionStatus observable should only publish events related to connection state changes","user":{"login":"HNeukermans","id":2285199,"avatar_url":"https://avatars1.githubusercontent.com/u/2285199?v=3","gravatar_id":"","url":"https://api.github.com/users/HNeukermans","html_url":"https://github.com/HNeukermans","followers_url":"https://api.github.com/users/HNeukermans/followers","following_url":"https://api.github.com/users/HNeukermans/following{/other_user}","gists_url":"https://api.github.com/users/HNeukermans/gists{/gist_id}","starred_url":"https://api.github.com/users/HNeukermans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HNeukermans/subscriptions","organizations_url":"https://api.github.com/users/HNeukermans/orgs","repos_url":"https://api.github.com/users/HNeukermans/repos","events_url":"https://api.github.com/users/HNeukermans/events{/privacy}","received_events_url":"https://api.github.com/users/HNeukermans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-09T09:30:08Z","updated_at":"2017-06-09T09:30:08Z","closed_at":null,"body":"Currently the connectionstatus observable publishes events unrelated to  connection state changes.\r\nThis is due to subscribing to too many callback methods on the connection object.\r\n\r\n```\r\nprivate wireUpStatusEventsAsObservable(): Observable<ConnectionStatus> {\r\n        let sStatus = new Subject<ConnectionStatus>();\r\n        let connStatusNames = ['starting', 'received', 'connectionSlow', 'reconnecting', 'reconnected', 'stateChanged', 'disconnected'];\r\n        // aggregate all signalr connection status handlers into 1 observable.\r\n        connStatusNames.forEach((statusName) => {\r\n            // handler wire up, for signalr connection status callback.\r\n            this._jConnection[statusName]((...args: any[]) => {\r\n                this._zone.run(() => {\r\n                    sStatus.next(new ConnectionStatus(statusName));\r\n                });\r\n            });\r\n        });\r\n        return sStatus;\r\n    }\r\n```\r\nSolution:\r\nsubscribing only to the jConnection stateChanged(function(){ }) callback method will give the desired result. "}}
{"actor":{"display_login":"HNeukermans"}}