{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/968","repository_url":"https://api.github.com/repos/ReactiveX/RxJava","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/968/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/968/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/968/events","html_url":"https://github.com/ReactiveX/RxJava/issues/968","id":29609489,"node_id":"MDU6SXNzdWUyOTYwOTQ4OQ==","number":968,"title":"What is the proper way to implement observable that get canceled after unsubscribe?","user":{"login":"lexer","id":108267,"node_id":"MDQ6VXNlcjEwODI2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/108267?v=4","gravatar_id":"","url":"https://api.github.com/users/lexer","html_url":"https://github.com/lexer","followers_url":"https://api.github.com/users/lexer/followers","following_url":"https://api.github.com/users/lexer/following{/other_user}","gists_url":"https://api.github.com/users/lexer/gists{/gist_id}","starred_url":"https://api.github.com/users/lexer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lexer/subscriptions","organizations_url":"https://api.github.com/users/lexer/orgs","repos_url":"https://api.github.com/users/lexer/repos","events_url":"https://api.github.com/users/lexer/events{/privacy}","received_events_url":"https://api.github.com/users/lexer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2014-03-17T23:45:58Z","updated_at":"2018-07-08T16:14:28Z","closed_at":"2014-05-16T18:59:44Z","author_association":"NONE","body":"Sample:\n\n``` java\nObservable<HttpResponse> observeResponse(String url) {\n  Observable<HttpResponse> observable = Observable.create(new Observable.OnSubscribeFunc<HttpResponse>() {\n     @Override\n     public Subscription onSubscribe(final Observer<? super HttpResponse> observer) {\n     HttpResponse response = null;\n      try {\n        response = httpClient.getResponse(url);\n        observer.onNext(response);\n        observer.onComplete();\n      } catch (Exeception e) {\n        observer.onError(e);\n      }\n\n      return new Subscription() {\n        @Override\n        public void unsubscribe() {\n            if (response != null) {\n              response.disconnect();\n            }\n        }\n      }\n     }\n  }\n\n  return observable;\n}\n```\n\nProblem with that implementation that unsubscribe don't interrupt execution. It seems that this block should be wrapped by FutureTask that got canceled in unsubscribe.\n\nProbably FutureTask is bad class to use and there is something build in to RxJava?\n"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/403298397","html_url":"https://github.com/ReactiveX/RxJava/issues/968#issuecomment-403298397","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/968","id":403298397,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzI5ODM5Nw==","user":{"login":"rorlig","id":293995,"node_id":"MDQ6VXNlcjI5Mzk5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/293995?v=4","gravatar_id":"","url":"https://api.github.com/users/rorlig","html_url":"https://github.com/rorlig","followers_url":"https://api.github.com/users/rorlig/followers","following_url":"https://api.github.com/users/rorlig/following{/other_user}","gists_url":"https://api.github.com/users/rorlig/gists{/gist_id}","starred_url":"https://api.github.com/users/rorlig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rorlig/subscriptions","organizations_url":"https://api.github.com/users/rorlig/orgs","repos_url":"https://api.github.com/users/rorlig/repos","events_url":"https://api.github.com/users/rorlig/events{/privacy}","received_events_url":"https://api.github.com/users/rorlig/received_events","type":"User","site_admin":false},"created_at":"2018-07-08T16:14:28Z","updated_at":"2018-07-08T16:14:28Z","author_association":"NONE","body":"@lexer how did you ultimately resolve this issue?"}}
{"actor":{"display_login":"rorlig"}}