February 2018
Intermediate to advanced
350 pages
7h 35m
English
Delegates are not only for initializing properties lately/lazily. As we learned, delegation enables the forwarding of getter and setter calls of a property to the delegate. This enables delegates to offer more cool features than just lately/lazily initialization.
One such cool feature comes with Delegates.observable. Think of a situation where you need to look out for the value change of a property, and perform some action as soon as this occurs. The immediate solution that comes to our mind is to override the setter, but this would look nasty and make codes complex, whereas delegates are there to save our life.
Have a look at the following example:
var myStr:String by Delegates.observable("<Initial ...Read now
Unlock full access