{"action":"created","issue":{"url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/13","labels_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/13/comments","events_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/13/events","html_url":"https://github.com/vert-x3/vertx-rx/issues/13","id":96523681,"number":13,"title":"Observable<HttpClientResponse> should end() on subscribe()","user":{"login":"dctr","id":3601172,"avatar_url":"https://avatars.githubusercontent.com/u/3601172?v=3","gravatar_id":"","url":"https://api.github.com/users/dctr","html_url":"https://github.com/dctr","followers_url":"https://api.github.com/users/dctr/followers","following_url":"https://api.github.com/users/dctr/following{/other_user}","gists_url":"https://api.github.com/users/dctr/gists{/gist_id}","starred_url":"https://api.github.com/users/dctr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dctr/subscriptions","organizations_url":"https://api.github.com/users/dctr/orgs","repos_url":"https://api.github.com/users/dctr/repos","events_url":"https://api.github.com/users/dctr/events{/privacy}","received_events_url":"https://api.github.com/users/dctr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"vietj","id":225674,"avatar_url":"https://avatars.githubusercontent.com/u/225674?v=3","gravatar_id":"","url":"https://api.github.com/users/vietj","html_url":"https://github.com/vietj","followers_url":"https://api.github.com/users/vietj/followers","following_url":"https://api.github.com/users/vietj/following{/other_user}","gists_url":"https://api.github.com/users/vietj/gists{/gist_id}","starred_url":"https://api.github.com/users/vietj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vietj/subscriptions","organizations_url":"https://api.github.com/users/vietj/orgs","repos_url":"https://api.github.com/users/vietj/repos","events_url":"https://api.github.com/users/vietj/events{/privacy}","received_events_url":"https://api.github.com/users/vietj/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-07-22T09:45:15Z","updated_at":"2015-09-08T09:24:19Z","closed_at":"2015-09-08T08:54:26Z","body":"Hello vert-rx,\r\n\r\na code sample in the official examples repo is as follows:\r\n\r\n```java\r\n    public void httpClientRequest(Vertx vertx) {\r\n        HttpClient client = vertx.createHttpClient(new HttpClientOptions());\r\n        HttpClientRequest request = client.request(HttpMethod.GET, 8080, \"localhost\", \"/the_uri\");\r\n        request.toObservable().subscribe(response -> {\r\n                // Process the response\r\n        }, error -> {\r\n                // Could not connect\r\n        });\r\n        request.end();\r\n    }\r\n```\r\n\r\nIn the sample, the subscribe() on the observable is analogous to the handler(...) in the non-rx world. However, in my opinion, the subscribe itself should trigger the end() by itself. This was the case with mod-rxvertx in Vert.x 2.\r\n\r\nMy usecase (simplified) is/was a function as follows:\r\n\r\n```java\r\npublic Observable<JsonObject> requestJsonResource(HttpClient client, String url) {\r\n    return client.get(url).toObservable().someMapReduceMagicToTransformResponseToJson(...);\r\n}\r\n```\r\n\r\nThe caller of the function then called subscribe() and got an Observable of a JsonObject. Now he would have to end the request, but as the request is managed under the hood, this is not possible.\r\n\r\nI then tried doing the following\r\n\r\n```java\r\n    ...\r\n    HttpClientRequest request = client.get(url);\r\n    return request.toObservable().doOnSubscribe(request::end).someTransformation(...)\r\n```\r\n\r\nBut as the doOnSubscribe triggers before the subscription happens, I get an exception that no handlers for the request which is about to being send is registered.\r\n\r\nI understand use cases, where you want to end() the request separately, but in my optionion either the doOnSubscribe variant should work, or a subscribe() should trigger the end() automatically, like with Vert.x 2's mod-rxvertx."},"comment":{"url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/comments/138493611","html_url":"https://github.com/vert-x3/vertx-rx/issues/13#issuecomment-138493611","issue_url":"https://api.github.com/repos/vert-x3/vertx-rx/issues/13","id":138493611,"user":{"login":"vietj","id":225674,"avatar_url":"https://avatars.githubusercontent.com/u/225674?v=3","gravatar_id":"","url":"https://api.github.com/users/vietj","html_url":"https://github.com/vietj","followers_url":"https://api.github.com/users/vietj/followers","following_url":"https://api.github.com/users/vietj/following{/other_user}","gists_url":"https://api.github.com/users/vietj/gists{/gist_id}","starred_url":"https://api.github.com/users/vietj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vietj/subscriptions","organizations_url":"https://api.github.com/users/vietj/orgs","repos_url":"https://api.github.com/users/vietj/repos","events_url":"https://api.github.com/users/vietj/events{/privacy}","received_events_url":"https://api.github.com/users/vietj/received_events","type":"User","site_admin":false},"created_at":"2015-09-08T09:24:19Z","updated_at":"2015-09-08T09:24:19Z","body":"yes it makes sense"}}