This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-24
Channels
- # aleph (1)
- # beginners (43)
- # calva (22)
- # cider (51)
- # clerk (1)
- # clj-kondo (20)
- # clojure (29)
- # clojure-denmark (1)
- # clojure-europe (73)
- # clojure-finland (28)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-spec (7)
- # clojure-uk (4)
- # clojurescript (12)
- # data-science (2)
- # datomic (51)
- # events (1)
- # fulcro (20)
- # hyperfiddle (28)
- # integrant (6)
- # malli (20)
- # matrix (2)
- # music (1)
- # off-topic (66)
- # reitit (17)
- # releases (5)
- # ring (1)
- # shadow-cljs (31)
- # xtdb (6)
I'm trying to derive new components out of other components by prepping the derived ones but that obviously doesn't work because the keys don't exist in the map (so prep-key doesn't run). What's the right way to do that with integrant? Example in ๐งต
Given this configuration
{:aws/config {:x :y}}
I want to end up with something like:
{:aws/s3-client cognitect.aws.client.impl.Client
:aws/sqs-client cognitect.aws.client.impl.Client
...}
I don't need aws/config but I don't mind if it remains there. What I do want is to have the new keys for these specific clients. I also don't want to require them in the configurationI have init-key defmethods for :aws/s3-client and :aws/sqs-client and they work if the keys exist. When the keys don't exist I get the result that I want if I manually assoc the values when loading the config (and before I run ig/init) but that feels like cheating. Is there a way to force integrant to initialize the components (S3 and SQS in the example) even when their keys are missing?
No, not currently. Duct has a layer on top of Integrant that does that; basically there's a pre-processing step where certain keys can modify the configuration. You could do something similar, perhaps adding a method that expands the key or updates the whole configuration.
Nice, I'll check it out, thanks for integrant @U0BKWMG5B!
No problem! Thanks for posing the question; it's one I thought about a lot when creating Duct, but coming back to it fresh has given me a few ideas.