{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2805","repository_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2805/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2805/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2805/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2805","id":149509373,"number":2805,"title":"Lazily call 'then' for chaining SignalProducers","user":{"login":"gbrhaz","id":701651,"avatar_url":"https://avatars.githubusercontent.com/u/701651?v=3","gravatar_id":"","url":"https://api.github.com/users/gbrhaz","html_url":"https://github.com/gbrhaz","followers_url":"https://api.github.com/users/gbrhaz/followers","following_url":"https://api.github.com/users/gbrhaz/following{/other_user}","gists_url":"https://api.github.com/users/gbrhaz/gists{/gist_id}","starred_url":"https://api.github.com/users/gbrhaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbrhaz/subscriptions","organizations_url":"https://api.github.com/users/gbrhaz/orgs","repos_url":"https://api.github.com/users/gbrhaz/repos","events_url":"https://api.github.com/users/gbrhaz/events{/privacy}","received_events_url":"https://api.github.com/users/gbrhaz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-19T16:14:03Z","updated_at":"2016-04-19T17:04:39Z","closed_at":null,"body":"I have two SignalProducers. The second one relies upon the other fetching something and setting a property elsewhere. Unfortunately, in order for this to work I have to wrap the second SignalProducer in another SignalProducer like so:\r\n\r\n```\r\nreturn SignalProducer {\r\n            sink, _ in\r\n            \r\n            self.create().start {\r\n                event in\r\n                sink.forwardEvent(event)\r\n            }\r\n        }\r\n```\r\n\r\nBecause the `create` method gets the property that the first signal sets, the first signal needs to finish. With the way `then` works, all code gets executed straight away, and then the signals are chained, but if something is referenced that hasn't yet been set, the app will obviously crash. \r\n\r\nWhat is the solution to this problem? I'd rather not have the above code because it looks ugly and adds so much noise."},"comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments/212019355","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2805#issuecomment-212019355","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2805","id":212019355,"user":{"login":"gbrhaz","id":701651,"avatar_url":"https://avatars.githubusercontent.com/u/701651?v=3","gravatar_id":"","url":"https://api.github.com/users/gbrhaz","html_url":"https://github.com/gbrhaz","followers_url":"https://api.github.com/users/gbrhaz/followers","following_url":"https://api.github.com/users/gbrhaz/following{/other_user}","gists_url":"https://api.github.com/users/gbrhaz/gists{/gist_id}","starred_url":"https://api.github.com/users/gbrhaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbrhaz/subscriptions","organizations_url":"https://api.github.com/users/gbrhaz/orgs","repos_url":"https://api.github.com/users/gbrhaz/repos","events_url":"https://api.github.com/users/gbrhaz/events{/privacy}","received_events_url":"https://api.github.com/users/gbrhaz/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T17:04:39Z","updated_at":"2016-04-19T17:04:39Z","body":"`flatMap` does indeed work. I'm curious what the point of `then` is now...\r\n\r\nYou're right, outside state is extremely frustrating at this point. I like the idea of `replayLazily`. Do you know of any additional use-cases outside of the one you made the comment on? "}}