Fork me on GitHub
#fulcro
<
2020-04-08
>
Chris O’Donnell03:04:15

Published a couple more blog posts to my fulcro + pathom series at https://chrisodonnell.dev/. One implements a couple of pathom parser tests, and the second adds authentication and basic authorization to API calls. Always happy to hear any feedback. 🙂

simple_smile 28
currentoor04:04:53

thanks for doing this!

👍 8
currentoor04:04:01

fulcro needs more blog posts

folcon08:04:49

I dropped one down myself as a review post, super impressed with what comes out of the box…

fulcro 12
adamfeldman14:04:33

Hunted down the link to your blog post, hope you don’t mind me sharing it here @U0JUM502E https://folcon.github.io/posts-output/2020-04-07-Fulcro-Review-PLUS-websockets/

folcon14:04:54

Ah, no problem =)…

nick17:04:39

That's awesome! Thanks for sharing @U0DUNNKT2

👍 4
Jakub Holý (HolyJak)08:04:31

@tony.kay Regarding ☝️ , how can I get access to the ::pathom/errors part of the response? When I look at the response or its :body inside a :remote-error? function, it is nowhere to be found. (And there is :error :none, :error-text nil) Do I need to add a :global-eql-transform that adds ::pathom/errors to every query to be able to read it?

tony.kay14:04:18

Yes, global-query-transform is the perfect place for that kind of thing. Sorry that isn’t in the book…that’s what I do on my projects.

Jakub Holý (HolyJak)11:04:59

The defmacro docstring does not really describe the handler names supported out of the box such as action, ok-action, refresh, ... . Where are they documented? Thanks!

tony.kay14:04:03

The default-result-action is the place for that doc, since the macro does nothing more that look up what you’ve configured on the app and calls it.

Tuomas13:04:10

Hi, a fulcro and clojure newbie here. I think I’ve learned a lot of new concepts thanks to the awesome documentation and video series, but I’m still struggling a bit. I have a product, product list and product editor like so.

(defsc Product [this {:product/keys [id name]}]
  {:query         [:product/id :product/name]
   :ident         :product/id})

(defsc ProductEditor [this {:product/keys [id name description]}]
  {:query [:product/id :product/name :product/description]
   :ident :product/id})

(defsc ProductList [this {:product-list/keys [items selected-product]}]
  {:ident         (fn [] [:component/id ::product-list])
   :query         [{:product-list/items (comp/get-query Product)}
                   {:product-list/selected-product (comp/get-query ProductEditor)}])
I can transact a new product into the :product/id table and its ident into the product list :component/id { ::product-list { :product-list/items } } . I can also edit the attributes of the newly made product (in the ProductEditor) and it’s values are changing in the :product/id table which is reflected in the product list and editor. I also have a similar setup for :process/id . My problem is, that I need to be able to add processes to the product. I naively tried to just make an options list directly out of the app state atom, but of course the process options list doesnt know it needs to update if a new process is made. I also tried to get-query from ProcessList, but I kept getting nil. Should I have subcomponent with the same ident as ProcessList or something like that? I’m not sure if I’m on the right track at all.

cjmurphy14:04:34

If product is to have many processes then I would expect to see :product/processes (as a join so comp/get-query to a Process component) in a component that has :product/id as its ident. Then in a mutation you would need to be creating the process (a map at [:process/id id]) and reference to it (an ident at [product/id id :product/process]) in app state.

Tuomas16:04:44

Thanks for replying. Yes a product can have many processes. I sort of get the idea of adding a process to a product, but what I’m actually struggling with is displaying the processes that you can choose from (which is all the processes). In a way the “process options”-list doesn’t belong to a product, but is in fact something global. How should you go about querying for global data in a simple component? Should you even?

Tuomas17:04:01

Now that I have thought about this more, I actually think I should just add something like :ui/options and give it the proper list ident

cjmurphy22:04:58

That's a good question. I did end up storing all lookup information in app state in three components. But I don't know if I would recommend that necessarily. This kind of problem is talked about in the videos if you watch them. But if you need the selected process that is :product/process, and if you need all of them then that is :ui/processes, which is what you have as :ui/options, because as you can see, you don't want to be querying for the processes every time - the query for them fits well as a df/load from :client-did-mount. So I think your solution is good.

🙏 4
folcon19:04:24

Looking at server config section, it doesn’t mention how to do defaults? Is it possible to lookup an env var and if that fails, default to some value?

tony.kay20:04:23

put env lookup in defaults.edn, and the override in your specific config file (i.e. prod.edn). if you mean “a default if it isn’t configured in files”: CLJ already has a way…`(get config key dflt)`

folcon21:04:02

Got it use the (get config key dflt) in code.