{"action":"created","issue":{"url":"https://api.github.com/repos/fjcaetano/RxWebSocket/issues/3","repository_url":"https://api.github.com/repos/fjcaetano/RxWebSocket","labels_url":"https://api.github.com/repos/fjcaetano/RxWebSocket/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/fjcaetano/RxWebSocket/issues/3/comments","events_url":"https://api.github.com/repos/fjcaetano/RxWebSocket/issues/3/events","html_url":"https://github.com/fjcaetano/RxWebSocket/issues/3","id":329025616,"node_id":"MDU6SXNzdWUzMjkwMjU2MTY=","number":3,"title":"It would be nice to disable automatically connect when the Socket Object is initialized","user":{"login":"hoanglu14","id":39908401,"node_id":"MDQ6VXNlcjM5OTA4NDAx","avatar_url":"https://avatars1.githubusercontent.com/u/39908401?v=4","gravatar_id":"","url":"https://api.github.com/users/hoanglu14","html_url":"https://github.com/hoanglu14","followers_url":"https://api.github.com/users/hoanglu14/followers","following_url":"https://api.github.com/users/hoanglu14/following{/other_user}","gists_url":"https://api.github.com/users/hoanglu14/gists{/gist_id}","starred_url":"https://api.github.com/users/hoanglu14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoanglu14/subscriptions","organizations_url":"https://api.github.com/users/hoanglu14/orgs","repos_url":"https://api.github.com/users/hoanglu14/repos","events_url":"https://api.github.com/users/hoanglu14/events{/privacy}","received_events_url":"https://api.github.com/users/hoanglu14/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-04T12:01:00Z","updated_at":"2018-06-07T14:05:09Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI think it is a good idea ti allow developer to choose when to trigger the socket connection. Sometimes I just need to initialize the socket object first, write all the beautiful reactive codes then start the connection. Like this\r\n\r\n```\r\noverride func react() {\r\n        let socket = RxWebSocket(url: \"ws://lcocalhost:1337\")\r\n    \r\n        let connect = socket.rx.connect\r\n            .do(onNext: { _ in\r\n                self.socket.write(string: self.varUsername.value ?? \"Unknown user\")\r\n                self.varIsConnected.value = true\r\n            })\r\n            .map { true }\r\n\r\n        let disconnect = socket.rx.disconnect\r\n            .do(onNext: { error in\r\n                self.varIsConnected.value = false\r\n            })\r\n            .map { _ in false}\r\n\r\n        Observable.of(connect,disconnect).merge() ~> varIsConnected => disposeBag\r\n    }\r\n```\r\n\r\nThen somewhere in the app, I would call \r\n```\r\n lazy var connectAction: Action<Void?, Void> = {\r\n        return Action() { _ in\r\n            if self.socket.isConnected {\r\n                self.socket.disconnect()\r\n            } else {\r\n                self.socket.connect()\r\n            }\r\n            return .just(())\r\n        }\r\n    }()\r\n```\r\n\r\nBut this cannot be achieved since the connection started by the time this happens\r\n`        let socket = RxWebSocket(url: \"ws://lcocalhost:1337\")\r\n`\r\n"},"comment":{"url":"https://api.github.com/repos/fjcaetano/RxWebSocket/issues/comments/395432362","html_url":"https://github.com/fjcaetano/RxWebSocket/issues/3#issuecomment-395432362","issue_url":"https://api.github.com/repos/fjcaetano/RxWebSocket/issues/3","id":395432362,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTQzMjM2Mg==","user":{"login":"fjcaetano","id":1066295,"node_id":"MDQ6VXNlcjEwNjYyOTU=","avatar_url":"https://avatars3.githubusercontent.com/u/1066295?v=4","gravatar_id":"","url":"https://api.github.com/users/fjcaetano","html_url":"https://github.com/fjcaetano","followers_url":"https://api.github.com/users/fjcaetano/followers","following_url":"https://api.github.com/users/fjcaetano/following{/other_user}","gists_url":"https://api.github.com/users/fjcaetano/gists{/gist_id}","starred_url":"https://api.github.com/users/fjcaetano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fjcaetano/subscriptions","organizations_url":"https://api.github.com/users/fjcaetano/orgs","repos_url":"https://api.github.com/users/fjcaetano/repos","events_url":"https://api.github.com/users/fjcaetano/events{/privacy}","received_events_url":"https://api.github.com/users/fjcaetano/received_events","type":"User","site_admin":false},"created_at":"2018-06-07T14:05:09Z","updated_at":"2018-06-07T14:05:09Z","author_association":"OWNER","body":"@hoanglu14 this may be interesting indeed, but I'm a bit hesitant of changing the current behavior, perhaps we could have a `shouldAutoconnect: Bool` argument on the initializer and set it to `true` by default. This way, you could send `false` and connect manually. What do you think about that?\r\n\r\nAlso, how do you feel about writing a PR for this?"}}
{"actor":{"display_login":"fjcaetano"}}