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
-
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
Identifiable
by 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: () -> UUID
The thing is I can't put these objects in anIdentifiedArrayOf
orIdentifiedArray
since they're notIdentifiable
nor have a keypath to an ID (the requirements for theIdentifiedArray
initializers.I'm thinking however would it be an option to give some more api to an extension of
Array
where the element isIdentified
. Then I can just map over my objects to wrap them in anIdentified
struct and supply that with myenv.uuid
(
Identified
has an initializerinit(value: Value, id: (Value) -> ID
)This could be done by just matching the api of
IdentifiedArray
in an extension or extracting that out to a protocol and conform bothIdentifiedArray
and[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