{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2200","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2200/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2200/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2200/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2200","id":96288395,"number":2200,"title":"RAC3: Disposables do not properly clean up chained signals","user":{"login":"robertjpayne","id":214288,"avatar_url":"https://avatars.githubusercontent.com/u/214288?v=3","gravatar_id":"","url":"https://api.github.com/users/robertjpayne","html_url":"https://github.com/robertjpayne","followers_url":"https://api.github.com/users/robertjpayne/followers","following_url":"https://api.github.com/users/robertjpayne/following{/other_user}","gists_url":"https://api.github.com/users/robertjpayne/gists{/gist_id}","starred_url":"https://api.github.com/users/robertjpayne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertjpayne/subscriptions","organizations_url":"https://api.github.com/users/robertjpayne/orgs","repos_url":"https://api.github.com/users/robertjpayne/repos","events_url":"https://api.github.com/users/robertjpayne/events{/privacy}","received_events_url":"https://api.github.com/users/robertjpayne/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-21T11:07:38Z","updated_at":"2015-07-22T02:50:24Z","closed_at":null,"body":"Comparing RAC3 to RAC2 we have two very similar examples:\r\n\r\n*RAC3*\r\n```swift\r\nlet signalAndObserver = Signal<AnyObject?, NoError>.pipe()\r\nlet signal: Signal<AnyObject?, NoError> = signalAndObserver.0\r\n\r\nlet disposable =\r\nsignal\r\n    |> map { (value: AnyObject?) -> String in\r\n        println(\"SHOULD ONLY BE CALLED ONCE\")\r\n        return \"NEW VALUE\"\r\n    }\r\n    |> observe(next: { _ in\r\n        println(\"NEXT\")\r\n    })\r\n\r\nsendNext(signalAndObserver.1, \"ONE\")\r\ndisposable?.dispose()\r\nsendNext(signalAndObserver.1, \"TWO\")\r\n```\r\n\r\n*RAC2*\r\n```objc\r\nstatic RACSubject *subject;\r\nsubject = [RACSubject subject];\r\n\r\nRACDisposable *d = [[subject map:^id(id value) {\r\n    NSLog(@\"SHOULD ONLY BE CALLED ONCE\");\r\n    return @\"NEW VALUE\";\r\n}] subscribeNext:^(id x) {\r\n    NSLog(@\"NEXT\");\r\n}];\r\n\r\n[subject sendNext:@\"ONE\"];\r\n[d dispose];\r\n[subject sendNext:@\"TWO\"];\r\n```\r\n\r\nIn both cases the goal is to to transform the results of the signal, and subscribe to that transformed stream. Once the subscription is disposed the transformation of the signal should be disposed as well.\r\n\r\nIn RAC2 this snippet of code properly disposes of the `map` while in RAC3 the `map` continues to be subscribed until the signal is terminated.\r\n\r\nIs there a different way I should be accomplishing this in RAC3? I have loads of places where I'm using transforms that I've now discovered are not actually dropping subscriptions. Most are harmless but using an `[unowned self]` results in some nasty crashes."},"comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments/123543984","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2200#issuecomment-123543984","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2200","id":123543984,"user":{"login":"robertjpayne","id":214288,"avatar_url":"https://avatars.githubusercontent.com/u/214288?v=3","gravatar_id":"","url":"https://api.github.com/users/robertjpayne","html_url":"https://github.com/robertjpayne","followers_url":"https://api.github.com/users/robertjpayne/followers","following_url":"https://api.github.com/users/robertjpayne/following{/other_user}","gists_url":"https://api.github.com/users/robertjpayne/gists{/gist_id}","starred_url":"https://api.github.com/users/robertjpayne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertjpayne/subscriptions","organizations_url":"https://api.github.com/users/robertjpayne/orgs","repos_url":"https://api.github.com/users/robertjpayne/repos","events_url":"https://api.github.com/users/robertjpayne/events{/privacy}","received_events_url":"https://api.github.com/users/robertjpayne/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T02:50:24Z","updated_at":"2015-07-22T02:50:24Z","body":"@brow yea I came to that conclusion, is there any 'easy' way to convert a signal into a signal producer that can then have side effects injected?\r\n\r\nRight now I'm manually managing that but I think it'd be highly valuable to have that into the core library and would be happy to contribute a PR if there's not already an easy way to do it. Something as simple as:\r\n\r\n```swift\r\nsignal.producer |> map { \"New Value\" } |> start()\r\n```\r\n\r\nAt this point if the signal is terminated the producer will get those event(s) too and if the disposable for the producer is triggered the producer will clean itself up and remove it's subscription from the signal."}}