[swift-users] What is the intended response to Array change notification for dependents?

Edward Connell ewconnell at gmail.com
Tue Mar 7 10:08:14 CST 2017

Thank you Jens, that is exactly the point of my question. 
At the moment in pure swift there is no incremental array change API for observers. This must have been considered by the library designers. 

My question is, what was their design intent? Rebuild all dependents every time?

Sent from my iPhone

> On Mar 7, 2017, at 7:59 AM, Jens Alfke <jens at mooseyard.com> wrote:
>> On Mar 6, 2017, at 11:36 PM, Rien via swift-users <swift-users at swift.org> wrote:
>> On 07 Mar 2017, at 03:56, Edward Connell via swift-users <swift-users at swift.org> wrote:
>> I would like to have an Array implementation where I get more information than just "the whole thing changed". 
>> As a value type I get it, but lets say it's a list of 500 image info structs and it's bound to UI. You change one item, now the whole array changes and you have to rebuild the entire visual tree right? Rebuilding the state of dependent objects can be really expensive, not just UI things.
> In Apple’s Foundation framework, Key-Value Observing (KVO) fills this need, and can be used with NSMutableArray, including when it’s bridged to Swift. But it doesn’t really transfer to a pure Swift environment since arrays are value types: changing one item is actually replacing the entire array with a new one (optimized through clever internal data-sharing.)
> I would assume that the people working on the design of the Swift Foundation library are thinking about similar observer APIs, but I don’t know the details.
> ―Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170307/d7165995/attachment.html>

More information about the swift-users mailing list