[swift-evolution] [Discussion] Allow injection of `didSet` and `willSet`
davesweeris at mac.com
Mon Jul 11 18:00:05 CDT 2016
> On Jul 8, 2016, at 6:45 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> It’s clear that we should decide on when our observer will be executed. In the example from above I pretended that my observer will be executed after the observer from the module itself.
> When we set a.member2 the observer for member1 on our side will be called first, follows by member2 observer, which ‘might’ not be what we need.
> I’d suggest that if this ‘feature’ might ever be considered for Swift that we should be able to set the execution order.
> observe(first) // called before observer from the module are called
> observe(last) // called after the observer from the module where called
I think I’d say that your “local” willset should be called before the module’s, and your local didset should be called after the module’s. This ensures that module’s code executes closest to when the memory gets changed.
- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution