Skip to content

Instantly share code, notes, and snippets.

@basilche
Created July 9, 2019 04:45
Show Gist options
  • Save basilche/035e8fc76a19cb74d11b8a286ec2e12a to your computer and use it in GitHub Desktop.
Save basilche/035e8fc76a19cb74d11b8a286ec2e12a to your computer and use it in GitHub Desktop.
@objc dynamic var titleKVO: String = ""
var titleObserver: Observable<String> {
return rx.observe(String.self, "titleKVO", options: .new) //using an Rx wrapper for KVO we can monitor new values of
}
let disposeBag = DisposeBag()
titleObserver
.subscribe(onNext: { title in
titleLabel.text = title
})
.disposed(by: disposeBag)
.disposed(by: disposeBag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment