Fork me on GitHub

Hello! I seek feedback on a new section added to my "When UI Components and Data Entities Diverge", titled "" 🙏

Timofey Sitnikov11:04:40

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  ""
                                       :email ""
                                       :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?


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


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

Timofey Sitnikov12:04:11

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


What if you print the whole config?


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 Sitnikov14:04:07

How do you print the whole config?


(pprint config) Do you use REPL?

Björn Ebbinghaus15:04:57

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

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

(println config)
(println (:auth-mail config))
I added a rudimentary email service to my app two weeks ago:

Timofey Sitnikov22:04:46

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

Timofey Sitnikov22:04:54

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

Timofey Sitnikov22:04:28

@U0522TWDA and @U4VT24ZM3, 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.


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

Timofey Sitnikov10:04:52

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


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 Sitnikov13:04:39

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

❤️ 1

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 Sitnikov13:04:18

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.