Are the answers to the Swift version also?
A SignalPipe image that observes changes in an object property. When subscribing to a signal from several other objects, i.e. queue.queueCountSignal.observeNext({...}) , the watch block will be executed the next time the property changes. Is there a way to query the current value or call the watch function of NextBlock?
I do not want to use SignalProducer (which can be run explicitly) because it would mean that I need to collect observeNext blocks from each object that needs a signal. I also do not want to create several signal manufacturers for the same - or is it really necessary?
Here is sample code to make it more understandable
import ReactiveCocoa class SwipingQueueWithSignals<T> : SwipingQueue<T> { override var count: Int { didSet(oldQueueCount) { let newQueueCount = self.count queueCountSignalObserver.sendNext(newQueueCount) } let queueCountSignal: Signal<Int, NoError> private let queueCountSignalObserver: Observer<Int, NoError> init() { (self.queueCountSignal, self.queueCountSignalObserver) = Signal<Int, NoError>.pipe() super.init() } }
source share