[ANN] Extended https://github.com/fulcro-community/fulcro-exercises/blob/master/src/holyjak/fulcro_exercises.cljs#L280 - as always, feedback very much desired.
It is harder to learner also because it covers more and does more. Helix is trivial - but it has only UI, no idea of data and remote access. But you are right, materials are a part of it.
The fulcro developers guide is awesome and explains everything in a way that even a beginner can grasp. Re-frame documentation is certainly more fun to read but only scratches the surface. If only there were some video tutorials for beginners in fulcro that would certainly help.
What kind of tutorials do you have in mind? Tony has made a ton of videos...
If you come upon a good video that matches this for reagent or some other framework, please let me know! It is also a question of how much it should teach: Emacs config? ClojureScript? JavaScript interop? React? HTML and CSS? ... I am not sure where the boundary should go....
Jacek Schae has made the first parts of his classes for Reagent and Reframe available for free. The one on Reagent helped me a lot to put together all the pieces I had in my head after reading documents and looking at various examples on GitHub. There is also a lot of very good stuff around for Clojure and ClojureScript. Emacs/Spacemacs is also covered quite well, there are excellent videos by John Stevenson but focussed on Clojure. I had some difficulties in mimicking Tony‘s setup for Fulcro with shadowcljs but I figured it out after some tries and some help from Slack. You can definitely make your way through all the basics if you stay on the ball. Examples what I still find difficult after reading your tutorials and Tony‘s videos and documentation are understanding the graph database „syntax“ of Pathom and Fulcro and how this would translate to a relational database on the backend. I am still searching for some good material for this. It really depends on where you are coming from. I have my background on large and complex data integration frameworks, never messed around with UIs, no Java, no OO. So maybe not the best example for a typical beginner. 😉
Thank you! So you main challenge is understanding what Pathom resolvers to write and how to map those to an underlying SQL DB, correct?
Yes, exactly.
Nice.
Two comments.
L296 ((comp/factory Address) address)
I think this shouldn't be thought. 🙂
L318 [(h1 "Teams") (map ui-team teams)]
This will lead to warnings from react, because of missing keys, doesn't it?
L318 as well:
(cond loading? (...) :else (...))
→ (if loading? (...) (...)
Except for when you want the reader to use more states beside loading
(cond
(df/loading? marker) (p "Loading...")
(df/failed? marker) (p "Failed." (button "Load again"))
:else (...)
Or
(let [status (:status marker)]
(case status
:loading (p "Loading...")
:failed (p "Failed." (button "Load again"))
(...)
Right. It is extracted from code that had more conditions but you are right that of makes more sense here.
@mroerni Could you please explain what you mean by your first comment regarding L296? Of course I could have defined the factory separately but this also goes, no?
Sure. It „works“ but I would consider it bad style. I would always write (def ui-address (comp/factory Address))
I have it from the second code example under https://book.fulcrologic.com/#_demo_using_unions_as_a_ui_type_selector Why is it "bad"? Because you create a new factory on each render, perhaps, and thus it is not efficient?
I think it's just a style thing. 🙂
Better readable code, less code repetition ... You know? Performance could be a thing as well I guess.
In general I also def factories separately, so we agree here. I only make an exception, well, exceptionally 🙂
Regarding the cond
- I left it as is but inserted a line with ;; ...
before the else to hint that more cases could be handled there (as is the case in the Minim. F. Tutorial that this exercises are meant for).
Thanks a lot!
does anyone know why I get this warning when I use a union with initial-state? get-ident returned an invalid ident: [nil nil] nil
I guess the props passed to the component are nil
, no? Is that expected or a mistake? Does it make sense to render the component without any data? If it does then either ignore the warning or use :initial-state {}
(+ propagating it all the way up) to make sure there are non-nil props.
But given then this ident seems dynamic, i.e. props-dependent, why would you render the component when it has no props?
What surprises me is [nil nil]
, should it not be [:some-entity-name/id nil]
? Also, do you have latest Fulcro? I would expect some of the warnings inside it to be triggered?! See https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/components.cljc#L630
Hi! I will check. The problem is that this is a union. Initial state is calculated from the child component and thus should always pass on values to use as the ident.. (as I understand it).
it is nil nil and not some-entity/id nil because the union component supports different entity types
so the ident is defined as (defn [] [type id])
Upgraded to latest 3.4.22. Same message.
I am not familiar with unions. But it still looks like initial state issue to me (and you can check that by looking into the client db). Also, why is type nil? That should likely not happen?
can you share a gist of the relevant code?
Sorry for the late reply. The code is as follows:
(defsc Step [this {:keys [id type] :as props}]
{:initial-state (fn [params] (comp/get-initial-state Start))
:query (fn [] {:start (comp/get-query Start)
:length (comp/get-query Length)})
:ident (fn [] [type id])
}
But I think I will let it be for now.
@holyjak btw, I read you blog... we're both in Norway. I live in Stavanger. I don't think there are too many Clojure or at least Fulcro developers around here.
Oh, nice! Now, last time I mentioned Fulcro in #clojure-norway I got no reaction. I have some job to do here. Man må aldri gi opp... 🙂
haha.. det er sant... jeg melder meg inn i kanalen så kan jeg svare 😉
the app renders fine.. it is only initially it is passed null values for the ident
Thank you for your work. I always felt (and was told) that fulcro is somewhat hard to learn. And I contribute that to the small amount of beginner material and be it questions on StackOverflow. That's the reason why I decided to ask questions in the GitHub discussion section. 🙂 Slack is nice to talk "face-to-face", but it doesn't generate lasting value in the form of learning material.