I've recently started to convert from RAC 3 to RAC 4 and found out that takeUntil
on SignalProducer
now accepts SignalProducer
as opposed to Signal
in RAC 3.
This is my current method in extension SignalType
and it feels pretty hackish:
func toSignalProducer() -> SignalProducer<T, E> {
return SignalProducer { (sink, _) in
self.observe(
next: { t in sendNext(sink, t) },
completed: { _ in sendCompleted(sink) }
)
}
}
Can I improve this? Thanks!
There is a takeUntil
overload of SignalProducer
that takes a Signal
from v4.0.0-alpha.2: https://github.com/ReactiveCocoa/ReactiveCocoa/blob/v4.0.0-alpha.2/ReactiveCocoa/Swift/SignalProducer.swift#L557
Time for an update! Thanks :+1:
@ikesyo Just for curiosity, is my approach of converting Signal
to SignalProducer
sub-optimal? Can this be done better? I see most interoperability between Signal
and SignalProducer
comes by lift
ing Signal
's operators to accept SignalProducer
(and rightly so). Is converting Signal
to SignalProducer
frowned upon?
This is already available in the framework! :)
let producer = SignalProducer(signal: signal)
That essentially creates a producer with no side effects (see #2449)
Most helpful comment
This is already available in the framework! :)
That essentially creates a producer with no side effects (see #2449)