Skip to content

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

Answered by stephencelis
ACFancy asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ACFancy
Comment options

You must be logged in to vote
5 replies
@stephencelis
Comment options

@ACFancy
Comment options

@stephencelis
Comment options

@ACFancy
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants