ReactiveCocoa / ReactiveObjCBridge

Bridge between ReactiveObjC and ReactiveSwift
MIT License
63 stars 39 forks source link

Property bridging #40

Closed erwald closed 6 years ago

erwald commented 6 years ago

I found myself bridging between RACSignals and Property values a lot, and thought this could be a generally useful (if small) feature.

Basically, this PR allows us to do:

// RACSignal -> Property
let racSignal = RACSignal<NSNumber>.return(NSNumber(value: 10))
let property = Property(initial: 0, then: racSignal) // Property<NSNumber> == 10

// Property -> RACSignal
let property = Property<Int>(initial: 0, then: SignalProducer(value: 10))
let racSignal = property.map(NSNumber.init(value:)).bridged // RACSignal<NSNumber>

I also deleted a couple of unused functions (I think they're not needed anymore) and rearranged things to be a bit more nicely grouped, with section headers etc.

Thoughts?

mdiep commented 6 years ago

I think I'm 👎 on this.

The RACSignal -> Property could be of some use, but it's only a minor convenience since you can bridge to a producer first.

I'm definitely 👎 on Property -> RACSignal because it hides the choice between the Signal and SignalProducer—i.e. whether it sends the current value first. Since .producer.bridged isn't much more code, I don't think it's worth hiding that choice.

erwald commented 6 years ago

Fair enough, I'll close it. 😄