Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a RACSignal to a SignalProducer in ReactiveCocoa 5?

In ReactiveCocoa 4, we could convert a RACSignal into a SignalProducer using toSignalProducer(). This method does not exist in ReactiveCocoa 5, so how can we do the same thing?

like image 461
Luke Avatar asked Mar 14 '17 15:03

Luke


1 Answers

Use bridgedSignalProducer() in ReactiveObjCBridge:

someSignal.toSignalProducer()

becomes

bridgedSignalProducer(from: someSignal)

This produces a SignalProducer<Value?, AnyError>. Unlike RAC 4's startWithNext(), RAC 5's startWithValues() is only on SignalProducers whose Error type is NoError. To get around this, I added a utility function on SignalProducer that behaves the same way as startWithValues but works with any Error type (ignoring any error.)

like image 90
Luke Avatar answered Oct 11 '22 13:10

Luke