You can do either. If you pass the config as a dependency, then you have to
access it in the `start` method after dependency injection has occurred.

Sometimes it is useful to write a constructor function to initialize the
component. If that constructor needs access to the config it must be passed
to the function, not provided as a dependency.

On Sat, Apr 6, 2024, 1:00 AM dieter.v...@gmail.com <
dieter.van.ees...@gmail.com> wrote:

> Hello,  I'm playing a bit with the 'Component' library. The system has
> some initial configuration (port numbers, uri's, usernames,...) in code.
>
> I'm doubting to eighter pass configuration when constructing the system:
> (C/system-map
>  :mycomponent  (map->MyComponent {:conf ...})
>
> OR to pass configuration itself as a component
> (defrecord Config ...)
> (C/system-map
> :config ...
> :mycomponent
>    (C/using (map->MyComponent ...) [:config])
>
> Is there any reason why to prefer one way over the  other or is it just
> personal preference?
>
> kind regards,
> Dieter
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/2abcf943-e885-4e17-9856-0247959115dcn%40googlegroups.com
> <https://groups.google.com/d/msgid/clojure/2abcf943-e885-4e17-9856-0247959115dcn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CADQBrAT3fcv10bbwESWf8AHJouzx_nKrTZbO9BZ04%3DoKMrH19g%40mail.gmail.com.

Reply via email to