[swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`

Adrian Zubarev adrian.zubarev at devandartist.com
Fri Jul 8 04:10:44 CDT 2016


Hello dear Swift community, I’m not sure if this was discussed before or not, but I really want to know if something like this is welcome for the future Swift version. If this topic was already discussed, I’m apologizing for bringing it back to life in a new thread.

Lets say I’ve got a third party module and I want to know when the a variable of some type has changed:

extension UIViewController {
     
    public override var view: UIView {
         
        willSet {
            // do something useful here
        }
         
        didSet {
            // do something useful here
        }
    }
}
Wouldn’t be handy to inject custom didSet and willSet functions into any property or computed property?

This would also allow us to build a proper two-way-binding mechanism.



-- 
Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160708/ba3cb562/attachment.html>


More information about the swift-evolution mailing list