Skip to content

Instantly share code, notes, and snippets.

@iby
Last active September 30, 2018 20:46
Show Gist options
  • Save iby/94436c4c45c2d01d58590fee37420a06 to your computer and use it in GitHub Desktop.
Save iby/94436c4c45c2d01d58590fee37420a06 to your computer and use it in GitHub Desktop.
class Foo: ReactiveExtensionsProvider {
let pipe = Signal<String, NoError>.pipe()
var bar: String = "Such bar!" {
didSet { self.pipe.input.send(value: self.bar) }
}
}
extension Reactive.Binds where Base: Foo {
var bar: BindingTarget<String> {
return self.reactive.makeBindingTarget({ $0.bar = $1 })
}
}
extension Reactive.Signals where Base: Foo {
var bar: Signal<String, NoError> {
return self.base.pipe.output
}
}
extension Reactive.Producers where Base: Foo {
var bar: SignalProducer<String, NoError> {
return self.reactive.signal.bar.producer.prefix(value: self.base.bar)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment