{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2668","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2668/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2668/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2668/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2668","id":127453831,"number":2668,"title":"How's the right way to change the definition of a signal but keeping the subscribed observers up to date.","user":{"login":"minuscorp","id":3819883,"avatar_url":"https://avatars.githubusercontent.com/u/3819883?v=3","gravatar_id":"","url":"https://api.github.com/users/minuscorp","html_url":"https://github.com/minuscorp","followers_url":"https://api.github.com/users/minuscorp/followers","following_url":"https://api.github.com/users/minuscorp/following{/other_user}","gists_url":"https://api.github.com/users/minuscorp/gists{/gist_id}","starred_url":"https://api.github.com/users/minuscorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minuscorp/subscriptions","organizations_url":"https://api.github.com/users/minuscorp/orgs","repos_url":"https://api.github.com/users/minuscorp/repos","events_url":"https://api.github.com/users/minuscorp/events{/privacy}","received_events_url":"https://api.github.com/users/minuscorp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-19T14:08:22Z","updated_at":"2016-01-19T16:30:53Z","closed_at":null,"body":"Hello.\r\n\r\nHow's the right way to subscribe to a signal that maybe is not created yet (because is the result of combining some others and that isn't done yet) and keeping the subscribers receiving next events to the most recent signal definition?\r\n\r\nWith cod, I've done this but don't know if that's the right way:\r\n\r\n```swift\r\nlet instantCurrent: MutableProperty<Float> = MutableProperty<Float>(0.0)\r\nlet instantVoltage: MutableProperty<Float> = MutableProperty<Float>(0.0)\r\nvar instantPower: Signal<Float,NoError> = Signal<Float,NoError>.never\r\n\r\ninit() {\r\n    zip(instantCurrent.producer.filter{ $0 > 0.5 }, instantVoltage.producer).map{ $0 * $1 }.startWithSignal{ signal in instantPower = signal.0 }\r\n}\r\n```\r\n\r\nAnd in other class I get subscribed to that ```instantPower``` and I'm assuming that the observing won't get anything because the signal is ```.never``` until I redefine the Signal and starts sending events.\r\n\r\nBut I got an error in the previous ```init()``` some lines later (just sometimes, not always):\r\n\r\n```swift\r\nself.batteryRemainingTime = combineLatest(averagePowerSignal, remainingEnergySignal).filter{ power, energy in return power > 0.0 }.map{ power, energy in  energy / power}\r\n```\r\n\r\nIs this produced because the definition of the ```instantPower``` signal changes its definition while ```combineLatest``` is being executed and for that reason this line should be moved into the ```.startWithSignal{ signal in instantPower = signal.0 ... }```?"},"comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments/172907929","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2668#issuecomment-172907929","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2668","id":172907929,"user":{"login":"avalanched","id":851640,"avatar_url":"https://avatars.githubusercontent.com/u/851640?v=3","gravatar_id":"","url":"https://api.github.com/users/avalanched","html_url":"https://github.com/avalanched","followers_url":"https://api.github.com/users/avalanched/followers","following_url":"https://api.github.com/users/avalanched/following{/other_user}","gists_url":"https://api.github.com/users/avalanched/gists{/gist_id}","starred_url":"https://api.github.com/users/avalanched/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avalanched/subscriptions","organizations_url":"https://api.github.com/users/avalanched/orgs","repos_url":"https://api.github.com/users/avalanched/repos","events_url":"https://api.github.com/users/avalanched/events{/privacy}","received_events_url":"https://api.github.com/users/avalanched/received_events","type":"User","site_admin":false},"created_at":"2016-01-19T16:30:53Z","updated_at":"2016-01-19T16:30:53Z","body":"```swift\r\nlet (signal, observer) = Signal<Float,NoError>.pipe()\r\nzip(floatProducerA, floatProducerB).map { /*to Float*/ }.start(observer)\r\nsignal.observeNext { print($0) }\r\n```"}}