Assigning an ImageViewModel to a UIImageView does not cancel the subscription to the viewModel's imageFlow when the UIView is deallocated.
class MyView: UIView {
private let myImageView = UIImageView()
var myViewModel: MyViewModel {
didSet {
myImageView.imageViewModel = myViewModel.imageViewModel
}
}
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(myImageView)
}
deinit {
// We need to manually set the image's viewModel to nil, otherwise the subscription to the imageFlow is never cancelled
myViewModel.imageViewModel = nil
}
}
Assigning an
ImageViewModelto aUIImageViewdoes not cancel the subscription to the viewModel'simageFlowwhen the UIView is deallocated.