fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
zhuxun2 2021-03-17T03:12:13.000600Z

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

zhuxun2 2021-03-17T03:14:02.002800Z

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.

zhuxun2 2021-03-17T03:16:15.004Z

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

zhuxun2 2021-03-17T03:18:22.006200Z

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]}]

zhuxun2 2021-03-17T03:23:20.007700Z

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

zhuxun2 2021-03-17T03:28:53.011Z

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 Rendtslev 2021-03-17T16:41:06.015Z

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

stuartrexking 2021-03-17T03:43:50.011100Z

@chetlind_clojure Thanks. This is much simpler.

tony.kay 2021-03-17T05:06:25.011800Z

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.kay 2021-03-17T05:08:09.012900Z

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

Marcus 2021-03-17T13:52:52.013100Z

@tony.kay Yes! I have read the four first chapters in your book now + the minimalist intro by Jakub. I've also just started on the fulcro 3 series on youtube. Which is the other one?

tony.kay 2021-03-17T15:44:55.013300Z

Grokking Fulcro on YouTube…it’s a lot more detailed. Not really for beginner beginners, but ok for ppl that have experience elsewhere

Aleksander Rendtslev 2021-03-17T16:41:06.015Z

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

hadils 2021-03-17T19:09:08.016600Z

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

tony.kay 2021-03-17T19:29:54.016700Z

https://book.fulcrologic.com/#_routing_targets

tony.kay 2021-03-17T19:30:01.016900Z

read: :will-enter

hadils 2021-03-17T19:37:47.017200Z

Thanks