Fork me on GitHub
#fulcro
<
2021-03-17
>
zhuxun203:03:13

I'm trying to implement a remote file tree viewer like this.

zhuxun203:03:02

The key requirement is laziness. I want to make it so that the initial remote request only asks for one level. Further requests for listing files in the sub-folders will only be sent when the triangle is clicked.

zhuxun203:03:15

I read through https://book.fulcrologic.com/#_recursive_queries but still have questions. How would you design the stated component?

zhuxun203:03:22

I'd imagine the initial request be something like this:

[:dir/id :dir/name
 {:dir/files [:file/id :file/name]}
 {:dir/sub-dirs [:dir/id :dir/name]}]

zhuxun203:03:20

But how would you write the :onClick function for the triangle?

zhuxun203:03:53

Another unrelated question: can I have a UI state :ui/xxx that is not shared between different views on the same entity? I don't want to use separate ids for them because I want the remote props be linked. This is very common requirement for e.g. implementing checkboxes on a tree view that have one node appearing at multiple locations.

Aleksander Rendtslev16:03:06

I would personally recommend using hooks for this. It's easy to reason about and it becomes very obvious that that is local state. And it works really well with Fulcro. Just set use-hooks? To true

tony.kay05:03:25

You can always use component-local state if you want a component-local value that is not part of the actual state in the fulcr odb

tony.kay05:03:09

on the laziness: your recursive query would just state 1 instead of , and then you’d pull the next level from the node that is expanded

hadils19:03:08

How do I pass props to a component that I'm routing to?

tony.kay19:03:01

read: :will-enter