fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
2020-12-27T01:29:51.345500Z

thank you, that makes more sense. I was mistakenly using the the shadow-cljs server url instead of the one spun up dev:datomic

Gleb Posobin 2020-12-27T03:10:51.345700Z

Yeah, I don't understand it...

Gleb Posobin 2020-12-27T03:11:50.345900Z

What if I don't have an ident? Like, I have the .../:username route, but the users are indexed by their ids and not usernames.

tony.kay 2020-12-27T03:37:31.346100Z

You pass a vector of strings to the route. It uses your route segments to turn that into the proper path parameters. This is all separate from idents and queries. It is pure data processing by the router with the intention of composition (of routers) and abstraction (not being tied to the idea of how routes are remembered (e.g. URL), navigated (back button), etc). Don’t conflate them. Dynamic routers are pure UI routers whose sole purpose is to get the right thing on the screen. For your convenience, the design is meant to be easy to use from a URL perspective (splitting a URL on / gives you the vector). The parameters to will-enter are purely from the vector and parameters you pass to change-route, and have nothing to do with the state db or query.

Gleb Posobin 2020-12-27T03:38:25.346400Z

I didn't know about the route params, and haven't seen the route params mentioned in the book (and can only find them now in the legacy routers section), that's why I asked.

Christopher Genovese 2020-12-27T03:55:10.346900Z

Thanks, Tony. That's very helpful. What's the best model to start with for creating a Mongo db adapter?

Christopher Genovese 2020-12-27T04:00:21.347100Z

Thanks, @tony.kay. That's very helpful. What's the best model to start with for creating a Mongo db adapter?

Gleb Posobin 2020-12-27T05:52:20.347300Z

Hmm, I see. But how do I get the result of the router match into the component? Say the route-segment is [:username] (or ["user" :username]), how do I get the username into the component? Is issuing a load/mutation in route-deferred the only way? There will be a delay then iiuc.

tony.kay 2020-12-27T06:13:54.347700Z

Make a mutation that puts it there and then changes the ui route.

tony.kay 2020-12-27T06:16:13.348Z

Look at rad kvstore

tony.kay 2020-12-27T06:17:42.348200Z

No problem 😊

tony.kay 2020-12-27T06:18:08.348400Z

Not even in doc strings?

Gleb Posobin 2020-12-27T07:21:23.348600Z

It is in the doc string, but didn't think to look there.

tony.kay 2020-12-27T17:31:07.349Z

The curse of too much documentation. I could easily add 100+ pages to the book covering these kinds of little details that are in docstrings.

1👍
Jakub Holý 2020-12-27T19:39:12.349400Z

Care to send a PR to add it to https://github.com/holyjak/awesome-fulcro?

1🤘
2020-12-27T20:40:45.349700Z

Yeah sure

1❤️
Mr. Savy 2020-12-27T21:02:28.352600Z

i've been trying to recreate the pagination example from the book without much success. :page/items still evals to an empty collection after doing a transaction, so I've been looking at the query being passed through the network to try to understand what's going on. I don't think I understand how this query is being evaluated. where is it being received?

Jakub Holý 2020-12-28T08:49:50.363900Z

Well, you knew the problem was that your query did not return the data you expected.... 🙂

tony.kay 2020-12-27T21:07:16.352900Z

Query looks fine. You’d need a resolver on server that can respond to that.

(defresolver paged-items [env input]
  {::pc/output [{:paginate/items [:item/id]}]}
  (let [params (-> env :ast :params)] {:paginate/items [{:item/id 1} ...}]}))

Mr. Savy 2020-12-27T21:36:26.353200Z

ok nice, it's reassuring to know my initial suspicion was right. For testing purposes, I was using the same resolver the book uses, which just about matches that one. However from what I can tell it never hits the resolver, but I'm not sure why. I read the main section in the book on resolvers, but I never saw anything that explained how the resolver receives the transactions. Does fulcro just add each created resolver to a list to check transaction against, or is there something else I need to do aside from just defining the resolver?

Helins 2020-12-27T21:56:05.354100Z

Is it normal that :initLocalState gets never updated on reload once it has been added? Full page refresh is necessary.

Helins 2020-12-28T11:42:03.364400Z

@holyjak Hot reloading by shadow-cljs Yes but :initLocalState does not seem to be updated even for newly mounted components (after the hot reload), and that is the part I find weird. Since they are newly mounted, they should call the newly reloaded ctor code, shouldn't they?

Jakub Holý 2020-12-28T12:16:29.364600Z

Are you 100% sure that hot reload did remount them? Perhaps add the on Component Mounted hook and log from there?

Helins 2020-12-28T14:25:33.366800Z

I am 100% sure that :initLocalState is never updated once it has been set once. That is, after modifying :initLocalState, even new components (which are mounted only after hot reload) do not execute the new code. I have to refresh the page myself.

tony.kay 2020-12-28T18:10:24.367800Z

well, then that would be a bug @adam678. Perhaps a regression? I’ve used that feature and do not remember such misbehavior, but perhaps I was using it in a circumstance where it didn’t matter

Helins 2021-01-08T12:04:42.248300Z

@tony.kay Sorry for the delay, I was in a rush. So, I was thinking that it was perhaps somehow because of my shadow-cljs config, since no one else was reporting this "obvious" behavior. But after tweaking a few things, the problem remains. It is not a mere regression since this is was I have always known, even in earlier versions. I guess I must be doing something wrong. However, it is really weird that only :initLocalState misbehave and absolutely nothing else.

tony.kay 2021-01-08T17:44:42.252400Z

Open an issue. Sounds like you can reproduce the issue. Should be easy to fix (I hope)

2020-12-27T22:02:36.354500Z

You need to register it with pathom.

1🎉
Mr. Savy 2020-12-27T22:19:51.354800Z

that did it, thank you both! I apologize for my ignorance. thankfully, the fulcro template has its own middleware set up with its own resolvers, so adding the new one to the def that exists in the pathom file allowed it to be registered with the rest and pick up the transaction. so as I now understand it, you have to create a def holding all your resolvers and then register that with the pathom parser plugin? this looks like it matches what's in section 4.12, so I'm going to spend some time comparing this section with the template.

2020-12-27T22:41:21.355Z

That's correct. 👍

Jakub Holý 2020-12-27T22:51:50.355300Z

I guess it is only called when the component is mounted so this behavior wouldn't surprise me. Though not sure what you mean by "reload". Reload button in the browser?

Jakub Holý 2020-12-27T22:55:19.355500Z

Under https://blog.jakubholy.net/2020/troubleshooting-fulcro/#_backend_pathom if you follow "Query does not return the expected data" - "Is there a resolver for the property/join in question" you will get to "If missing: have you created the resolver? Have you registered it with Pathom" and info how to chech / troubleshoot it

1👍
Mr. Savy 2020-12-27T23:11:44.356Z

thank you! when I initially thought it was a frontend/query design issue I did refer to your guide (in particular, the "`load!` from the server" section). now that I am starting to get exposure with resolvers this will be a good section to read through as well. if I had only known it was a resolver issue sooner, I may have thought to go over that section! 🤦