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-04-19T10:45:40.147500Z

Hello! I seek feedback on a new section added to my "When UI Components and Data Entities Diverge", titled "https://blog.jakubholy.net/2020/fulcro-divergent-ui-data/#_accessing_top_level_data_from_a_nested_component" 🙏

Timofey Sitnikov 2021-04-19T11:32:40.152200Z

Good morning! How do I add and use a configuration in config/defaults.edn? for example, I want to add the following configuration:

:server-components/auth-email/config {:host  "<http://smtp.gmail.com|smtp.gmail.com>"
                                       :email "<mailto:myemail@gmail.com|myemail@gmail.com>"
                                       :pass "my-password"
                                       :port 587}}
Then I have a namespace server-components/auth-email and in that namespace, I would like to use the configurations in that namespace, do I need to declare a keyword config ? How do I get these configs to use them?

Timofey Sitnikov 2021-04-20T22:21:46.162600Z

@holyjak and @mroerni, sorry for the late response, I can only work on Clojure during certain times 😞. OK, yes to @holyjak, that is exactly right.

Timofey Sitnikov 2021-04-20T22:33:54.162800Z

@mroerni, OK, I followed your example and it clarified it.

Timofey Sitnikov 2021-04-20T22:43:28.163200Z

@holyjak and @mroerni, as I am going through the journey of learning Clojure and Fulcro, I keep getting tripped up by little stuff like this. This is completely unexpected to me, but the config/defaults.edn is 100% Fulcro thing and it is basically handled by the com.fulcrologic.fulcro.server.config namespace. I did not catch that and that is why I was confused, but I was not asking you the right questions because I did not know from which angle to approach it, it looked magical to me. It is now super clear, but it was super hard to find the right chain to analyze and things like these make it challenging when learning Clojure. So, thank you for helping me to get to the bottom of it.

Jakub Holý 2021-04-21T09:48:09.163900Z

That is a big step, learning Clojure and Fulcro both at the same time. Best of luck!

Timofey Sitnikov 2021-04-21T10:01:52.164100Z

@holyjak you are not kidding me, but I have a hard time learning things that I do not use. So I wake up at 4:30 every morning, have my coffee and start learning Clojure till about 7:30. Then I exercise and then I start my work little past 8. Sounds crazy, but I love it ...

Jakub Holý 2021-04-21T11:40:41.164300Z

Incredible! I am a little afraid that you have bitten a little too much of the cake all at once but it is not up to me to judge 🙂 I hope you will do well!

Timofey Sitnikov 2021-04-21T13:32:39.164500Z

@holyjak, well the key is LOVE! When you love something its easy, I look forward to waking up and working on it!!

❤️ 1
Jakub Holý 2021-04-21T13:38:49.164800Z

Just remember that Clojure is as much about way of thinking and way of working (REPL-driven dev), if not more, than the language (listen to my recent podcast on the topic, if you want #news-and-articles)

Timofey Sitnikov 2021-04-21T13:46:18.165Z

Definitely! I use vim-iced and it is awesome, my source files become REPL, so I can execute lines inside (comment ...) blocks. I can type multiple-lines of commands, execute them, edit them, very powerful.

Jakub Holý 2021-04-19T11:54:28.152300Z

It is more less just data. Add whatever you want. See how eg fulcro-template reads it.

Jakub Holý 2021-04-19T11:55:22.152500Z

There is little magic for reading values from env vars, good for passwords

Timofey Sitnikov 2021-04-19T12:36:11.152700Z

@holyjak, how would I access that data? Its probably super obvious, I try to do this: (pprint (get config :host)) but I get a null. Should I read it through `(defstate config ...) ? Or is there already a variable that has already loaded configurations from the file?

Jakub Holý 2021-04-19T12:47:04.153200Z

What if you print the whole config?

Jakub Holý 2021-04-19T12:48:45.153400Z

Also config is just a nested map = the EDN. So you must ask for the key you used there, :server-components... It does not know or care which ns you call it from

Timofey Sitnikov 2021-04-19T14:10:07.153600Z

How do you print the whole config?

Jakub Holý 2021-04-19T14:23:08.153800Z

(pprint config) Do you use REPL?

Björn Ebbinghaus 2021-04-19T15:24:57.156500Z

@timofey.sitnikov When you follow the template: config is mount/defstate It is a singleton you can just require.

(ns whatever.server-components.auth-mail
  (:require
    [whatever.server-components.config :refer [config]))

(println config)
(println (:auth-mail config))
I added a rudimentary email service to my app two weeks ago: https://github.com/hhucn/decide3/blob/master/src/main/decide/server_components/email.clj#L40 https://github.com/hhucn/decide3/blob/master/src/main/config/prod.edn#L20

☝️ 1
Jakub Holý 2021-04-19T16:25:27.157200Z

From the point of repl, once your app started / mounted, it is just a var containing data, isn't it? So you can just look at it in the REPL. Does it look as you expect or not?

Luis Thiam-Nye 2021-04-19T19:55:37.158300Z

I think it is well presented 👍. The key takeaway I got from it is that it is best practice not to be querying for ident tables directly (eg :friend/id but rather maintain a separate list :all-friends). That would solve some of my problems. But what if all friends were not needed and instead it was desired to display a filtered view? Would you still populate :all-friends with all the friends, and then do the filtering and/or sorting in the MyFriends component?