This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-08
Channels
- # announcements (14)
- # babashka (12)
- # beginners (140)
- # calva (2)
- # cider (22)
- # clj-commons (14)
- # clj-kondo (49)
- # cljdoc (34)
- # clojure (92)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-new-zealand (2)
- # clojure-nl (2)
- # clojure-norway (60)
- # clojure-uk (17)
- # clojured (2)
- # clojurescript (7)
- # community-development (3)
- # conjure (2)
- # cryogen (13)
- # cursive (4)
- # data-oriented-programming (2)
- # datahike (5)
- # datomic (12)
- # defnpodcast (10)
- # events (2)
- # fulcro (20)
- # gratitude (3)
- # honeysql (4)
- # introduce-yourself (3)
- # jobs (10)
- # lsp (58)
- # malli (12)
- # missionary (19)
- # off-topic (8)
- # pathom (18)
- # podcasts-discuss (1)
- # polylith (41)
- # releases (1)
- # remote-jobs (3)
- # shadow-cljs (52)
- # spacemacs (1)
- # sql (37)
- # xtdb (19)
I’m new to Fulcro, so maybe I’m doing something wrong, but my graph has become disconnected and I’m not sure what’s the right way to reconnect it.
I added a new component into an existing hierarchy like
A -> B -> C
to
A -> b' -> B -> C
(in my case b'
is a router)
But my root query no longer works because B and C are getting disconnectedI’m also not confident I’m storing a list of items correctly.
I have the list at [:component/id ::ListComponent :root/list]
I’m even more confused because I manually added the missing edge in the repl (or so I thought) and it’s not registering through the router.
So, I managed to resolve the issue, although I’m not totally clear on how this worked.
I added :initial-state
options down the tree to the components I was trying to manually add, and then since they existed in the graph, everything was traversable.
most problems for beginners are making sure there is initial data in the db, which is always just that: Have an initial-state declaration on your components so that Fulcro can put them in your DB for you. If you don't list those, Fulcro expects you'll put them there some other way (e.g. loads)...which is then up to you during initialization
This https://blog.jakubholy.net/2020/fulcro-divergent-ui-data/#_inserting_a_stateful_ui_component_between_a_parent_child_entities might clarify And as https://fulcro-community.github.io/guides/tutorial-minimalist-fulcro/index.html#_components_initial_state states: > :initial-state ... to establish links (edges) between (typically singleton) components / data entities in the client DB.
In the RAD demo, there’s this code to set up routes in the menu:
(ui-dropdown-menu {}
(ui-dropdown-item {:onClick (fn [] (rroute/route-to! this InvoiceList {}))} "View All")
(ui-dropdown-item {:onClick (fn [] (form/create! this InvoiceForm))} "New")
(ui-dropdown-item {:onClick (fn [] (rroute/route-to! this AccountInvoices {:account/id (new-uuid 101)}))} "Invoices for Account 101")
(ui-dropdown-item {:onClick (fn [] (rroute/route-to! this AccountInvoices {:account/id (new-uuid 102)}))} "Invoices for Account 102"))) ; <=== I added this
I added a new menu item for “Invoices for Account 102” — the problem is, if I show invoices for 101, and then select invoices for 102, the screen doesn’t update.
I’m assuming it’s because the route is the same — is there a way to force Fulco to reload the report, to show the invoices for 102? (Not sure I’m even using the right language). THANK YOU!Probably should be considered a bug. It isn't technically the same route because the parameters are different, but because you are not exiting and re-entering the route the state machine won't be told.
betting it works fine if you go out and back in...so, you CAN manually call the code that the route event calls: form/start-form!
, though you should probably also call the code that stops the old one. The real solution is for the routing to actually cause the exit/enter events itself 😄
See also form-will-leave
and form-will-enter
...that's the pair that normally runs from the router events
The use-case in your example is kind of a corner that almost no one will hit...when do you do explicit entity routing like that...it was just a dumb example to show the methods could be called.
Mostly you'll go back to a report that lists them and pick a diff one, which will exit/enter and not cause issue
Thanks so much the hints here, @U0CKQ19AQ —
Just to make sure I’m tracking: AccountInvoices
is a report, not a form, correct? Do I still need to call form/start-form!
?
(Still hacking away on this, determined to get this to work. 🙂 And yes, a workaround is just to call another conventional report, which is “fine”. 🙂