Replies: 1 comment
-
@stephencelis @mbrandonw any advice would be appreciated :) |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Hi All,
I have been stuck for a while on something I have been trying to build in TCA:
Use Case: Need to show a hierarchical drop down list of a user's backed up file system from a backend service and then listen to a stream of "deltas" aka any changes to the backend to update the file system and update the view accordingly (like status of a file changed, file added, file deleted, etc)
What I Have Tried: Two different flavors of SwiftUI's representation of hierarchal lists:
https://www.iosdevie.com/p/swiftui-groupbox-outlinegroup-disclosuregroup
Outline Group you just pass a nested array into a list view. In TCA i can listen for changes to this array and run reducer actions based on the streamed changes to the trie structure and the view gets nicely re-rendered. I do not have access to on expanded events though, so I cannot use lazy loading. This would put strain on the backend service to retrieve ALL the watched files and folders at once.
https://swiftuirecipes.com/blog/file-tree-with-expanding-list-in-swiftui
Disclosure Group I can listen to on expand and collapse events, but I am having trouble isolating state into the root node. I am recursively creating new views for the children with their own stores to track a directory and its children based on the expanded/collapsed status. Right now I have a store per node in the trie and do not know how to communicate between them. My hope is to keep the state of this trie in one place and not have child states.
Here is my tree reducer and tree view for the disclosure group
Problem with Implementation: You can see I am creating new state for children with their own separate view so I cannot drill down into subchildren of children and update them. This will cause inconsistencies and require every node to gave its own TCP connection established
What I'm Looking For: An efficient way to use TCA to store a hierarchal file system and dynamically change it over time without putting too much strain on a backend service and any additional considerations I need to make. Please reach out to me here if you have any ideas or need more clarifications. I really appreciate it.
Beta Was this translation helpful? Give feedback.
All reactions