{"repo":"pointfreeco/swift-identified-collections","free":true,"listed":false,"github":"https://github.com/pointfreeco/swift-identified-collections","clone":"git clone https://github.com/pointfreeco/swift-identified-collections.git","description":"A library of data structures for working with collections of identifiable elements in an ergonomic, performant way.","language":"Swift","stars":623,"topics":["swiftui","swift-composable-architecture","identifiable","data-structures"],"license":"MIT","category":"mobile-apps","readme_excerpt":"Swift Identified Collections A library of data structures for working with collections of identifiable elements in an ergonomic, performant way. Motivation When modeling a collection of elements in your application's state, it is easy to reach for a standard Array . However, as your application becomes more complex, this approach can break down in many ways, including accidentally making mutations to the wrong elements or even crashing. 😬 For example, if you were building a \"Todos\" application in SwiftUI, you might model an individual todo in an identifiable value type: And you would hold an array of these todos as a published field in your app's view model: A view can render a list of these todos quite simply, and because they are identifiable we can even omit the id parameter of List : If your deployment target is set to the latest version of SwiftUI, you may be tempted to pass along a binding to the list so that each row is given mutable access to its todo. This will work for simple cases, but as soon as you introduce side effects, like API clients or analytics, or want to write unit tests, you must push this logic into a view model, instead. And that means each row must be able to communicate its actions back to the view model. You could do so by introducing some endpoints on the view model, like when a row's completed toggle is changed: This code is simple enough, but it can require a full traversal of the array to do its job. Perhaps it would be more performant for a r","default_branch":null,"files":null,"tree":[],"storefront":"/r/pointfreeco","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/pointfreeco/swift-identified-collections/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}