{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxSwing/issues/3","labels_url":"https://api.github.com/repos/ReactiveX/RxSwing/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxSwing/issues/3/comments","events_url":"https://api.github.com/repos/ReactiveX/RxSwing/issues/3/events","html_url":"https://github.com/ReactiveX/RxSwing/issues/3","id":42722212,"number":3,"title":"SwingObservable subscribe/unsubscribe: Who has to ensure it's done on the EDT?","user":{"login":"samuelgruetter","id":2394355,"avatar_url":"https://avatars.githubusercontent.com/u/2394355?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelgruetter","html_url":"https://github.com/samuelgruetter","followers_url":"https://api.github.com/users/samuelgruetter/followers","following_url":"https://api.github.com/users/samuelgruetter/following{/other_user}","gists_url":"https://api.github.com/users/samuelgruetter/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelgruetter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelgruetter/subscriptions","organizations_url":"https://api.github.com/users/samuelgruetter/orgs","repos_url":"https://api.github.com/users/samuelgruetter/repos","events_url":"https://api.github.com/users/samuelgruetter/events{/privacy}","received_events_url":"https://api.github.com/users/samuelgruetter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2014-09-14T14:53:52Z","updated_at":"2015-03-16T16:22:11Z","closed_at":null,"body":"When updating my [Swing RxScala examples](https://github.com/samuelgruetter/rx-playground) to RxScala 0.20.4, I suddenly got many `java.lang.IllegalStateException: Need to run in the event dispatch thread`. I found out that the changes which broke my apps came from https://github.com/ReactiveX/RxJava/pull/883, and I also read the discussion in https://github.com/ReactiveX/RxJava/pull/869. There, I learnt that not only modifications of the UI, but also modifications of the listeners (addXxxListener/removeXxxListener) have to run on the event dispatch thread. I had only respected the first, but not the second of these constraints. Knowing this, it was easy to fix my apps. Problem solved, end of the story ;-)\r\n\r\nBut when I looked at the new SwingObservable, I found an asymmetry: When I subscribe to a Swing Observable, I have to ensure myself that I'm on the event dispatch thread, otherwise an IllegalStateException is thrown (see [this line](https://github.com/ReactiveX/RxSwing/blob/0.x/src/main/java/rx/swing/sources/KeyEventSource.java#L43)).\r\nHowever, when I unsubscribe, I can do so from any thread, and the Swing Observable ensures that the unsubscription is run on the event dispatch thread (see [this line](https://github.com/ReactiveX/RxSwing/blob/0.x/src/main/java/rx/swing/sources/KeyEventSource.java#L62)).\r\n\r\nThis seems to be an inconsistent way of distributing the responsabilities between the library and the library users. @zsxwing do you agree? Or is there a good reason for this asymmetry that I'm missing?"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxSwing/issues/comments/81773010","html_url":"https://github.com/ReactiveX/RxSwing/issues/3#issuecomment-81773010","issue_url":"https://api.github.com/repos/ReactiveX/RxSwing/issues/3","id":81773010,"user":{"login":"headinthebox","id":1073054,"avatar_url":"https://avatars.githubusercontent.com/u/1073054?v=3","gravatar_id":"","url":"https://api.github.com/users/headinthebox","html_url":"https://github.com/headinthebox","followers_url":"https://api.github.com/users/headinthebox/followers","following_url":"https://api.github.com/users/headinthebox/following{/other_user}","gists_url":"https://api.github.com/users/headinthebox/gists{/gist_id}","starred_url":"https://api.github.com/users/headinthebox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/headinthebox/subscriptions","organizations_url":"https://api.github.com/users/headinthebox/orgs","repos_url":"https://api.github.com/users/headinthebox/repos","events_url":"https://api.github.com/users/headinthebox/events{/privacy}","received_events_url":"https://api.github.com/users/headinthebox/received_events","type":"User","site_admin":false},"created_at":"2015-03-16T16:22:11Z","updated_at":"2015-03-16T16:22:11Z","body":"The only goal of `subscribeOn` is to make sure the subscription and unsubscription happen on the specified scheduler. Any implementation that does not guarantee that has a bug. "}}