{"action":"created","issue":{"url":"https://api.github.com/repos/kzaher/RxSwift/issues/67","labels_url":"https://api.github.com/repos/kzaher/RxSwift/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/kzaher/RxSwift/issues/67/comments","events_url":"https://api.github.com/repos/kzaher/RxSwift/issues/67/events","html_url":"https://github.com/kzaher/RxSwift/issues/67","id":96990810,"number":67,"title":"Unsubscribing and timer","user":{"login":"Odrakir","id":724743,"avatar_url":"https://avatars.githubusercontent.com/u/724743?v=3","gravatar_id":"","url":"https://api.github.com/users/Odrakir","html_url":"https://github.com/Odrakir","followers_url":"https://api.github.com/users/Odrakir/followers","following_url":"https://api.github.com/users/Odrakir/following{/other_user}","gists_url":"https://api.github.com/users/Odrakir/gists{/gist_id}","starred_url":"https://api.github.com/users/Odrakir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Odrakir/subscriptions","organizations_url":"https://api.github.com/users/Odrakir/orgs","repos_url":"https://api.github.com/users/Odrakir/repos","events_url":"https://api.github.com/users/Odrakir/events{/privacy}","received_events_url":"https://api.github.com/users/Odrakir/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kzaher/RxSwift/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-24T07:48:18Z","updated_at":"2015-08-03T06:31:23Z","closed_at":"2015-08-03T06:31:23Z","body":"I'm trying to translate to RxSwift an example in the \"Intro to Rx\" web.(http://www.introtorx.com/Content/v1.0.10621.0/04_CreatingObservableSequences.html down where it creates a Timer)\r\n\r\nThis is what I have:\r\n\r\n        var ob:Observable<String> = create {\r\n            observer in\r\n            \r\n            var timer = NSTimer.schedule(repeatInterval: 1.0) { timer in\r\n                sendNext(observer, \"value\")\r\n                println(\"timer event \\(timer.fireDate)\")\r\n            }\r\n            \r\n            return AnonymousDisposable {\r\n               // timer.invalidate()\r\n            }\r\n        }\r\n        \r\n        var subscription = ob\r\n            >- subscribeNext {\r\n                e in\r\n                println(e)\r\n        }\r\n\r\n        var dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(3 * Double(NSEC_PER_SEC)))\r\n        dispatch_after(dispatchTime, dispatch_get_main_queue(), {\r\n            println(\"unsubscribe \\(subscription)\")\r\n            subscription.dispose()\r\n        })\r\n\r\nI'm trying to unsubscribe while keeping the timer running (as the example does) and then invalidate the timer in the dispose block (by uncommenting the \"timer.invalidate()\" line) to demonstrate the use of the disposable for cleaning purposes.\r\n\r\nThe problem is, with the code as it is, after the 3 seconds passed, the timer is still running (as expected) but the subscription seems to be active as well.\r\n\r\nThis is what I get:\r\n```\r\nvalue\r\ntimer event 2015-07-24 07:43:51 +0000\r\nvalue\r\ntimer event 2015-07-24 07:43:52 +0000\r\nvalue\r\ntimer event 2015-07-24 07:43:53 +0000\r\nunsubscribe RxSwift.AnonymousDisposable\r\nvalue\r\ntimer event 2015-07-24 07:43:54 +0000\r\nvalue\r\ntimer event 2015-07-24 07:43:55 +0000\r\n```\r\n\r\nIf I invalidate the timer, of course, I stop receiving events, but it seems I'm not unsubscribing for some reason."},"comment":{"url":"https://api.github.com/repos/kzaher/RxSwift/issues/comments/127139142","html_url":"https://github.com/kzaher/RxSwift/issues/67#issuecomment-127139142","issue_url":"https://api.github.com/repos/kzaher/RxSwift/issues/67","id":127139142,"user":{"login":"kzaher","id":1641148,"avatar_url":"https://avatars.githubusercontent.com/u/1641148?v=3","gravatar_id":"","url":"https://api.github.com/users/kzaher","html_url":"https://github.com/kzaher","followers_url":"https://api.github.com/users/kzaher/followers","following_url":"https://api.github.com/users/kzaher/following{/other_user}","gists_url":"https://api.github.com/users/kzaher/gists{/gist_id}","starred_url":"https://api.github.com/users/kzaher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kzaher/subscriptions","organizations_url":"https://api.github.com/users/kzaher/orgs","repos_url":"https://api.github.com/users/kzaher/repos","events_url":"https://api.github.com/users/kzaher/events{/privacy}","received_events_url":"https://api.github.com/users/kzaher/received_events","type":"User","site_admin":false},"created_at":"2015-08-03T06:31:22Z","updated_at":"2015-08-03T06:31:22Z","body":"These changes have been released in the latest release. Closing this issue. Let me know if it happens again."}}