{"action":"opened","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2256","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2256/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2256/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2256/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2256","id":100620402,"number":2256,"title":"[Question] How to begin work from the Next block Inline","user":{"login":"jeffreybergier","id":7349616,"avatar_url":"https://avatars.githubusercontent.com/u/7349616?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffreybergier","html_url":"https://github.com/jeffreybergier","followers_url":"https://api.github.com/users/jeffreybergier/followers","following_url":"https://api.github.com/users/jeffreybergier/following{/other_user}","gists_url":"https://api.github.com/users/jeffreybergier/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffreybergier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffreybergier/subscriptions","organizations_url":"https://api.github.com/users/jeffreybergier/orgs","repos_url":"https://api.github.com/users/jeffreybergier/repos","events_url":"https://api.github.com/users/jeffreybergier/events{/privacy}","received_events_url":"https://api.github.com/users/jeffreybergier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-12T19:46:48Z","updated_at":"2015-08-12T19:46:48Z","closed_at":null,"body":"Sorry, I know that title makes no sense. I'm new to functional programming and reactive cocoa and I've been struggling with an issue. I imagine its relatively simple. \r\n\r\nI am trying to get a list of SignalProducers to execute one after the other. However, some of the signal producers give another signal producer in the Next block of the execution instead of the completed. I am having trouble getting this part of the operation to happen inline.\r\n\r\nThe code I've written that works (but is super yucky) is pasted below. Also, at the very bottom of this post, is pseudo-code of what I'm hoping I can write instead. Lastly, the file I am working on is at https://github.com/jeffreybergier/Cartwheel/blob/master/Cartwheel/Cartwheel/CartListTableView/CartListTableCellViewController.swift\r\n\r\n``` swift\r\nvar macBuildsInProgress = 0\r\n        var iosBuildsInProgress = 0\r\n        var watchBuildsInProgress = 0\r\n        \r\n        self.cartfile.project.updateDependencies()\r\n            |> on(started: {\r\n                println(\"Updating Dependencies\")\r\n            })\r\n            |> on(completed: {\r\n                println(\"Finished Updating Dependencies\")\r\n                self.cartfile.project.buildCheckedOutDependenciesWithConfiguration(\"\", forPlatform: .Mac)\r\n                    |> start(next: { build in\r\n                        build\r\n                            |> on(started: {\r\n                                macBuildsInProgress++\r\n                                println(\"Mac Build has Started. In Progress = \\(macBuildsInProgress)\")\r\n                            })\r\n                            |> on(completed: {\r\n                                macBuildsInProgress--\r\n                                println(\"Mac Build has Completed. In Progress = \\(macBuildsInProgress)\")\r\n                            })\r\n                            |> start()\r\n                        \r\n                    })\r\n                self.cartfile.project.buildCheckedOutDependenciesWithConfiguration(\"\", forPlatform: .iOS)\r\n                    |> start(next: { build in\r\n                        build\r\n                            |> on(started: {\r\n                                iosBuildsInProgress++\r\n                                println(\"iOS Build has Started. In Progress = \\(iosBuildsInProgress)\")\r\n                            })\r\n                            |> on(completed: {\r\n                                iosBuildsInProgress--\r\n                                println(\"iOS Build has Completed. In Progress = \\(iosBuildsInProgress)\")\r\n                            })\r\n                            |> start()\r\n                        \r\n                    })\r\n                self.cartfile.project.buildCheckedOutDependenciesWithConfiguration(\"\", forPlatform: .watchOS)\r\n                    |> start(next: { build in\r\n                        build\r\n                            |> on(started: {\r\n                                watchBuildsInProgress++\r\n                                println(\"WatchOS Build has Started. In Progress = \\(watchBuildsInProgress)\")\r\n                            })\r\n                            |> on(completed: {\r\n                                watchBuildsInProgress--\r\n                                println(\"WatchOS Build has Completed. In Progress = \\(watchBuildsInProgress)\")\r\n                            })\r\n                            |> start()\r\n                        \r\n                    })\r\n            })\r\n            |> start()\r\n```\r\n\r\nI'd much rather the code look something more like this pseudocode\r\n\r\n``` swift\r\n        self.cartfile.project.updateDependencies()\r\n            |> then(self.cartfile.project.buildCheckedOutDependenciesWithConfiguration(\"\", forPlatform: .Mac))\r\n            |> doNext({ build in return build })\r\n            |> then(self.cartfile.project.buildCheckedOutDependenciesWithConfiguration(\"\", forPlatform: .iOS))\r\n            |> doNext({ build in return build })\r\n            |> then(self.cartfile.project.buildCheckedOutDependenciesWithConfiguration(\"\", forPlatform: .WatchOS))\r\n            |> doNext({ build in return build })\r\n            |> promoteErrors\r\n            |> on(complete: {\r\n                /* handle success */\r\n            })\r\n            |> on(fail: { errors in /*handle errors */ })\r\n            |> start()\r\n\r\n```"}}