Fork me on GitHub
#fulcro
<
2022-02-08
>
Brandon Olivier00:02: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.

Brandon Olivier00:02:00

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 disconnected

Brandon Olivier00:02:56

I’m also not confident I’m storing a list of items correctly. I have the list at [:component/id ::ListComponent :root/list]

Brandon Olivier00:02:25

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.

Brandon Olivier00:02:46

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.

👆 1
tony.kay01:02:20

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

genekim18:02:25

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!

tony.kay05:02:21

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.

tony.kay05:02:14

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 😄

tony.kay05:02:58

See also form-will-leave and form-will-enter...that's the pair that normally runs from the router events

tony.kay05:02:39

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.

tony.kay05:02:59

Mostly you'll go back to a report that lists them and pick a diff one, which will exit/enter and not cause issue

genekim20:02:34

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”. 🙂

genekim20:02:06

I actually thought this would work, but it didn’t:

(report/report-will-enter this {:account/id (new-uuid 101)} AccountInvoices)
(rroute/route-to! this AccountInvoices {:account/id (new-uuid 101)}))

tony.kay01:02:10

ah right...report...same exercise. Look at the report ns for the helpers

tony.kay01:02:21

route-to won't do anything because you're already there

tony.kay01:02:35

but will-enter logic should do it

tony.kay01:02:50

report has start-report!

genekim16:02:30

Thx — will look at again later today!