fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
Jakub Holý 2021-05-26T08:48:00.036200Z

[ANN] Extended https://github.com/fulcro-community/fulcro-exercises/blob/master/src/holyjak/fulcro_exercises.cljs#L280 - as always, feedback very much desired.

Jakub Holý 2021-05-27T07:46:03.045300Z

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.

Oliver 2021-05-28T21:29:31.059800Z

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.

Jakub Holý 2021-05-28T21:46:44.060Z

What kind of tutorials do you have in mind? Tony has made a ton of videos...

Jakub Holý 2021-06-01T08:08:07.081400Z

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

👍 1
Oliver 2021-06-01T19:28:32.107800Z

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. 😉

Jakub Holý 2021-06-02T09:48:43.115500Z

Thank you! So you main challenge is understanding what Pathom resolvers to write and how to map those to an underlying SQL DB, correct?

👍 1
Oliver 2021-06-03T05:22:34.121600Z

Yes, exactly.

Björn Ebbinghaus 2021-05-26T11:32:33.036900Z

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?

✅ 1
Björn Ebbinghaus 2021-05-26T11:39:58.037100Z

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"))
    (...)

Jakub Holý 2021-05-26T17:41:59.038Z

Right. It is extracted from code that had more conditions but you are right that of makes more sense here.

Jakub Holý 2021-05-26T19:20:30.038200Z

@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?

Björn Ebbinghaus 2021-05-26T19:23:09.040700Z

Sure. It „works“ but I would consider it bad style. I would always write (def ui-address (comp/factory Address))

Jakub Holý 2021-05-26T19:31:34.041300Z

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?

Björn Ebbinghaus 2021-05-26T19:34:14.041500Z

I think it's just a style thing. 🙂

Björn Ebbinghaus 2021-05-26T19:35:49.041700Z

Better readable code, less code repetition ... You know? Performance could be a thing as well I guess.

✅ 1
Jakub Holý 2021-05-26T19:55:31.042500Z

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!

Marcus 2021-05-26T22:29:03.044200Z

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

Jakub Holý 2021-05-27T07:55:35.045500Z

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

Marcus 2021-05-27T08:44:45.045800Z

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).

Marcus 2021-05-27T08:46:14.046Z

it is nil nil and not some-entity/id nil because the union component supports different entity types

Marcus 2021-05-27T08:46:37.046200Z

so the ident is defined as (defn []  [type id])

Marcus 2021-05-27T10:30:22.046400Z

Upgraded to latest 3.4.22. Same message.

Jakub Holý 2021-05-27T12:13:24.046600Z

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?

Jakub Holý 2021-05-27T12:20:36.046800Z

can you share a gist of the relevant code?

Marcus 2021-06-11T10:54:10.147600Z

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])
   }

Marcus 2021-06-11T10:54:26.147800Z

But I think I will let it be for now.

Marcus 2021-06-11T11:09:10.152100Z

@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.

Jakub Holý 2021-06-11T11:12:04.152300Z

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

Marcus 2021-06-11T11:13:37.152500Z

haha.. det er sant... jeg melder meg inn i kanalen så kan jeg svare 😉

Marcus 2021-05-26T22:32:07.044700Z

the app renders fine.. it is only initially it is passed null values for the ident

Björn Ebbinghaus 2021-05-26T23:27:33.044800Z

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.

👍 2
❤️ 1