Closed kasyanov-ms closed 6 years ago
Can you explain the use case ? Trying to think of when you’ll want to bind a nil image resource.
Thanks for opening the issue :)
protocol ViewModelProtocol {
var imageUrl: Signal<URL?> { get } // May return nil if no data from network call or we have a broken url string
}
class ViewController: UIViewController {
func setup() {
viewModel
.imageUrl
//.filter { $0 != nil }.map { $0! }
.emit(to: artworkView.kf.rx.image(placeholder: placeholder)) // Don't compile, should uncomment the previous line and move it into the viewmodel
.disposed(by: disposeBag)
}
}
Also it is impossible to use dynamic nature of Signal/Driver
without polluting the viewmodel with UIImage
's or dublicating placeholders. For example with the code above, this sequence [goodUrl, nil, goodUrl]
won't show the placeholder on the 2nd element
Fair point ! Will fix this soon.
Fixed in 0.1.1. Being deployed to CocoaPods as we speak: https://circleci.com/gh/RxSwiftCommunity/RxKingfisher/18
..to match original Kingfisher