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?
Asked
Active
Viewed 721 times
8

Luke
- 7,110
- 6
- 45
- 74
1 Answers
3
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 SignalProducer
s 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.)

Luke
- 7,110
- 6
- 45
- 74
-
`bridgedSignalProducer` has been superseded. You can now use `SignalProducer`'s `init
(_ signal: RACSignal – user2067021 Nov 18 '17 at 23:43)` initializer. -
@user2067021 can you guide me the usage you mentioned in your comment.I am unable to convert it :( – Muhammad Zohaib Ehsan Dec 05 '17 at 12:54
-
@Luke or can you guide me :) – Muhammad Zohaib Ehsan Dec 05 '17 at 12:57
-
2@MuhammadZohaibEhsan With ReactiveCocoa 7.0.1 and ReactiveObjcCBridge 2.0.0: `let racSignal = RACSignal
() let sigProd = SignalProducer(racSignal)` – user2067021 Dec 06 '17 at 23:58 -
Thanks @user2067021 really appreciate your help – Muhammad Zohaib Ehsan Dec 07 '17 at 06:10
-
Swift 4 / ReactiveCocoa 7.0.1 / ReactiveObjcCBridge 2.0.0 update Now it called `SignalProducer(_)`. For example if it was `rac_textSignal().toSignalProducer()` now it looks like: `SignalProducer(rac_textSignal())` – Nike Kov Jun 11 '18 at 10:21