TCA State is struct, but struct cannot have a stored property that recursively contains it, How TCA write code to design linked struct state #1342
-
QA
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Swift's https://forums.swift.org/t/using-indirect-modifier-for-struct-properties/37600/14 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I created a box solution tailored for TCA for those who may be interested: any feedback is welcomed. |
Beta Was this translation helpful? Give feedback.
Swift's
indirect
keyword allows for value types to be recursive and moves a type's storage onto the heap. It's an enum feature that can be applied to the whole enum or a specific case, so you could kinda twist your data model from a struct into an enum with a single case that tuples all your struct fields, or you could use a property wrapper:https://forums.swift.org/t/using-indirect-modifier-for-struct-properties/37600/14