Making external data identifiable #432
JaapWijnen
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an array of objects that I get from an api that I download at some point in my TCA app. Now these objects arent
Identifiableby themselves, but I want to display a list of navigationlinks linking to a detail page of each individual object. So in order to keep swiftUI happy I need to give them an ID which I'd do through my environment which contains avar uuid: () -> UUIDThe thing is I can't put these objects in anIdentifiedArrayOforIdentifiedArraysince they're notIdentifiablenor have a keypath to an ID (the requirements for theIdentifiedArrayinitializers.I'm thinking however would it be an option to give some more api to an extension of
Arraywhere the element isIdentified. Then I can just map over my objects to wrap them in anIdentifiedstruct and supply that with myenv.uuid(
Identifiedhas an initializerinit(value: Value, id: (Value) -> ID)This could be done by just matching the api of
IdentifiedArrayin an extension or extracting that out to a protocol and conform bothIdentifiedArrayand[Identified]to that same protocol. Any thoughts on this? Maybe this is not such a good idea and I should approach my problem in an entirely different way? Let me know! :)Beta Was this translation helpful? Give feedback.
All reactions