{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2453","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2453/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2453/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2453/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2453","id":110565238,"number":2453,"title":"How do I cancel the work of inner producers?","user":{"login":"bdolman","id":447184,"avatar_url":"https://avatars.githubusercontent.com/u/447184?v=3","gravatar_id":"","url":"https://api.github.com/users/bdolman","html_url":"https://github.com/bdolman","followers_url":"https://api.github.com/users/bdolman/followers","following_url":"https://api.github.com/users/bdolman/following{/other_user}","gists_url":"https://api.github.com/users/bdolman/gists{/gist_id}","starred_url":"https://api.github.com/users/bdolman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdolman/subscriptions","organizations_url":"https://api.github.com/users/bdolman/orgs","repos_url":"https://api.github.com/users/bdolman/repos","events_url":"https://api.github.com/users/bdolman/events{/privacy}","received_events_url":"https://api.github.com/users/bdolman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/milestones/5","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/milestones/4.0","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/milestones/5/labels","id":1167095,"number":5,"title":"4.0","description":"RAC4 targeting Swift 2","creator":{"login":"neilpa","id":42419,"avatar_url":"https://avatars.githubusercontent.com/u/42419?v=3","gravatar_id":"","url":"https://api.github.com/users/neilpa","html_url":"https://github.com/neilpa","followers_url":"https://api.github.com/users/neilpa/followers","following_url":"https://api.github.com/users/neilpa/following{/other_user}","gists_url":"https://api.github.com/users/neilpa/gists{/gist_id}","starred_url":"https://api.github.com/users/neilpa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neilpa/subscriptions","organizations_url":"https://api.github.com/users/neilpa/orgs","repos_url":"https://api.github.com/users/neilpa/repos","events_url":"https://api.github.com/users/neilpa/events{/privacy}","received_events_url":"https://api.github.com/users/neilpa/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":53,"state":"open","created_at":"2015-06-16T16:34:39Z","updated_at":"2015-11-05T21:26:42Z","due_on":null,"closed_at":null},"comments":16,"created_at":"2015-10-09T00:08:33Z","updated_at":"2015-11-07T00:45:46Z","closed_at":null,"body":"Let's say I have parallel work I want to do, such as downloading multiple images. Each of these downloads is represented by a SignalProducer. I create them and flatten them using the Merge strategy. When I start the outer producer and get a disposable I expected that disposing of that would also dispose of the inner producers. What actually happens is that after disposal, my outer producer stops receiving events, but the actual work being done by the inner producers continues, because they have not been disposed.\r\n\r\nHow do I get the actual work being done by the inner producers to stop? Here's some test code that illustrates the scenario:\r\n\r\n```swift\r\nfunc producerOfValues(values: [String]) -> SignalProducer<String, NoError> {\r\n    return SignalProducer<String, NoError> {observer, disposable in\r\n        for value in values {\r\n            sleep(1)\r\n            print(\"doing work: \\(value)\")\r\n            sendNext(observer, value)\r\n            if disposable.disposed { // 'disposed' is never true\r\n                print(\"producer disposed\")\r\n                break\r\n            }\r\n        }\r\n        sendCompleted(observer)\r\n    }\r\n}\r\n\r\nlet (signal, sink) = SignalProducer<SignalProducer<String, NoError>, NoError>.buffer(2)\r\nlet flattened = signal.flatten(.Merge)\r\n\r\nlet letterProducer = producerOfValues([\"a\", \"b\", \"c\"])\r\nlet numberProducer = producerOfValues([\"1\", \"2\", \"3\"])\r\n\r\nsendNext(sink, letterProducer.startOn(QueueScheduler()))\r\nsendNext(sink, numberProducer.startOn(QueueScheduler()))\r\nsendCompleted(sink)\r\n\r\nlet disposable = flattened.startWithNext {\r\n    print($0)\r\n}\r\ndisposable.dispose()\r\n```\r\n\r\nOutput:\r\n\r\n```text\r\ndoing work: a\r\ndoing work: 1\r\ndoing work: b\r\ndoing work: 2\r\ndoing work: c\r\ndoing work: 3\r\n```"},"comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments/154589329","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2453#issuecomment-154589329","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2453","id":154589329,"user":{"login":"mhuusko5","id":733409,"avatar_url":"https://avatars.githubusercontent.com/u/733409?v=3","gravatar_id":"","url":"https://api.github.com/users/mhuusko5","html_url":"https://github.com/mhuusko5","followers_url":"https://api.github.com/users/mhuusko5/followers","following_url":"https://api.github.com/users/mhuusko5/following{/other_user}","gists_url":"https://api.github.com/users/mhuusko5/gists{/gist_id}","starred_url":"https://api.github.com/users/mhuusko5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhuusko5/subscriptions","organizations_url":"https://api.github.com/users/mhuusko5/orgs","repos_url":"https://api.github.com/users/mhuusko5/repos","events_url":"https://api.github.com/users/mhuusko5/events{/privacy}","received_events_url":"https://api.github.com/users/mhuusko5/received_events","type":"User","site_admin":false},"created_at":"2015-11-07T00:45:46Z","updated_at":"2015-11-07T00:45:46Z","body":"It doesn't make sense, but it's a learning process ;)\r\n\r\nSo, an interruption of an outer producer isn't even *supposed* to lead to an interruption down the chain/of mapped producers?"}}