fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
jlmr 2021-06-14T14:34:52.176100Z

Hi, I’m still pretty new to Fulcro and am now working on my first non-trivial application. The frontend I’m building should render a data entity using different components based on some field in the entity and this is potentially recursive. I suspect I need dynamic queries, but I’m not sure. An example:

(defsc Widget [_this {:widget/keys [type] :as widget}]
  {:query [:widget/id :widget/type]
   :ident :widget/id}
  (case type
    :container (ui-container-widget widget)
    (dom/div (str "Don't know how to render " type))))
For now there is just one type. In this example ContainerWidget should also have access to the attribute :widget/children, which contains more widgets to render as Widget. Hopefully I’ve explained it clearly enough. Any help is very welcome!

Jakub Holý 2021-06-14T14:46:48.176200Z

I assume different types of widget have different data needs? If that is the case then I guess you need to use union queries. If widgets can contain widgets then you need to look into https://book.fulcrologic.com/#_recursive_queries - notice the {:person/children '...} .

jlmr 2021-06-14T14:53:11.176400Z

Indeed, different widgets have different data needs and can contain widgets. Thanks for pointing me in the right direction

👍 1
Jakub Holý 2021-06-14T14:56:09.176700Z

Good luck! I will one day need to dive into these myself to be able to write an advanced follow-up to the minimalist fulcro tutorial 🙂

Marcus 2021-06-14T18:58:52.182300Z

Hi! I render a form input field using some state as the field value. If I update state on every keystroke it works as expected. If I filter the value (e.g only allow the user to input numbers) the filtered value might be the same across multiple keystrokes. The effect is that there is no state change and thus no re-render and the user can enter garbage into the field. How can I handle this problem?

Marcus 2021-06-14T19:30:58.182800Z

Maybe this is not a problem if I use transact!!

Marcus 2021-06-15T19:45:57.192100Z

I figured out how to use transact!! in combination with StringBufferedInput. Works perfectly. 🙂

❤️ 1
Jakub Holý 2021-06-14T20:44:13.182900Z

Does this help?