Closed lukaskubanek closed 3 years ago
We're definitely open to it! I think it would be good to have an example use case, though, to see how it could improve a vanilla SwiftUI app. Would you be up for creating a small demo of its usage in a non-TCA app?
Somewhat tangentially, a feature request: selection management. Not sure whether it makes sense within the IdentifiedArray or in a separate type. Have you given it any thought? I like to think of IdentifiedArray a little like AppKit's NSArrayController, which handled selection which can get quite messy as I am finding at the moment.
@stephencelis: I haven’t yet fully adopted SwiftUI, and I’m using it mostly for previews of wrapped AppKit components. I thought that I would benefit from using IdentifiableArray
for iterating over multiple preview configurations in a ForEach
. In the end, I decided to go with a simple extension on ForEach
with an initializer that identifies individual elements based on their index. This means that I no longer have a use case, but probably there are still developers out there who might benefit from a separated package.
I'm going to convert this to a discussion so that folks can flesh out some ideas of how the type may be useful outside TCA. If it proves to be we'd definitely consider this in the future. Thanks for bringing it up!
I recently stumbled upon the implementation of
IdentifiedArray
in this repository, and I think that this struct is valuable on its own - especially when working with SwiftUI. Have you considered extracting it into its own package?