+1. This would allow us to create observers on any foreign variable. I'm far from a compiler right now but I wouldn't this syntax create a new variable instead of observing an existing one? Even if not, by reading this one could be mislead to believe so. Perhaps you should give it something to differentiate from creating a new var, for example by suppressing the type on this declaration.<br><br>On Friday, 8 July 2016, Adrian Zubarev via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><p>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.</p>
<p>Lets say I’ve got a third party module and I want to know when the a variable of some type has changed:</p>
<pre><code>extension UIViewController {
public override var view: UIView {
willSet {
// do something useful here
}
didSet {
// do something useful here
}
}
}
</code></pre>
<p>Wouldn’t be handy to inject custom <code>didSet</code> and <code>willSet</code> functions into any property or computed property?</p>
<p>This would also allow us to build a proper two-way-binding mechanism. </p>
<p></p></div><div><div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><br><div><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div></div><div><p></p></div></div></blockquote><br><br>-- <br>L<br>