-
-
Save soxjke/1659a9cec8eb1d03992dcf6df22756cf to your computer and use it in GitHub Desktop.
This file contains 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
struct RectangleConfig { | |
var width: Int = 0 | |
var height: Int = 0 | |
} | |
class ConfigView: NSView { | |
// Models | |
let config = MutableProperty<RectangleConfig?>(nil) | |
var width: SignalProducer<Int?, NoError>! | |
func awakeFromNib() { | |
// Extract config.width to self.width | |
// self.width should change when config.width changes, or when | |
// config changes | |
// self.width is Optional<Int> because config is Optional<RectangleConfig> | |
// and so if there is no config, then there is no width | |
self.width = config.producer.map { $0?.width } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment