pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.55k stars 1.45k forks source link

Extracting IdentifiedArray into its own package? #290

Closed lukaskubanek closed 3 years ago

lukaskubanek commented 4 years ago

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?

stephencelis commented 4 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?

mathieutozer commented 4 years ago

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.

lukaskubanek commented 4 years ago

@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.

stephencelis commented 3 years ago

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!