2

Since ReSwift is based around immutability of State, the Swift struct is obvious choice to work with.

But what if I really need a reference type property in a State to have a hierarchy of items? Let's say, my Model is composed with trees, so a TreeNode has to have a reference type to store a weak reference to its parent TreeNode. What is the best approach with ReSwift in this case?

Should I make a TreeNode object immutable and allocate a new one if the State is changed? Or maybe it's best to compose a TreeNode abstraction as an array of array of TreeNode structs (but in this case I will constantly search through that array of arrays in order to find a parent).

There's not much information about ReSwift and the community is not large enough yet. So, maybe I can have some discussion here? Thanks!

Vitalii Vashchenko
  • 1,777
  • 1
  • 13
  • 23

0 Answers0