ReactiveObjC
ReactiveObjC copied to clipboard
How does ReactiveCocoa bind the ImageView, listen to the ImageView and perform the setImage method?
How does ReactiveCocoa bind the ImageView, listen to the ImageView and perform the setImage method?
UIImageView can be bound with any ReactiveSwift primitive via its image binding target, as long as the RHS would not fail.
For example:
// `fetchAvatarFromNetwork` returns `SignalProducer<UIImage, MyError>`.
imageView.reactive.image <~ fetchAvatarFromNetwork()
// Ignore the error if the request has failed. So the placeholder would stay.
.flatMapError { _ in .empty }
// Set the image immediately to the placeholder.
.prefix(value: avatarPlaceholder)