This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // View Model layer | |
| final class Product { | |
| let title: String | |
| let text: String | |
| let imageUrl: URL | |
| // ... | |
| } | |
| // Networking layer | |
| func downloadImage(url: URL) -> SignalProducer<UIImage, NSError> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final class ProductTableViewCell: UITableViewCell { | |
| @IBOutlet var label: UILabel! | |
| @IBOutlet var imageView: UIImageView! | |
| @IBOutlet var titleLabel: UILabel! | |
| let viewModel: MutableProperty<Product?> | |
| var disposable: Disposable? | |
| deinit() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func awakeFromNib() { | |
| super.awakeFromNib() | |
| self.titleLabel.reactive.text <~ self.viewModel.map { $0?.title } | |
| self.label.reactive.text <~ self.viewModel.map { $0?.text } | |
| self.imageView.reactive.image <~ self.viewModel.producer.flatMap(.latest) { | |
| downloadImage($0.imageUrl).map(Optional.some).prefix(value: nil) | |
| } | |
| } |
OlderNewer