This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-08
Channels
- # announcements (6)
- # babashka (78)
- # beginners (84)
- # bristol-clojurians (5)
- # calva (50)
- # chlorine-clover (45)
- # cider (14)
- # clj-kondo (18)
- # cljs-dev (2)
- # clojars (2)
- # clojure (387)
- # clojure-android (3)
- # clojure-europe (6)
- # clojure-gamedev (3)
- # clojure-germany (3)
- # clojure-nl (18)
- # clojure-spec (5)
- # clojure-uk (36)
- # clojurescript (8)
- # clojurex (1)
- # conjure (1)
- # css (1)
- # cursive (32)
- # data-science (1)
- # datomic (11)
- # docker (61)
- # duct (17)
- # emacs (7)
- # figwheel-main (3)
- # fulcro (19)
- # jobs-discuss (3)
- # joker (1)
- # leiningen (23)
- # malli (11)
- # mount (6)
- # off-topic (30)
- # pathom (14)
- # pedestal (2)
- # phzr (1)
- # re-frame (11)
- # reagent (3)
- # reitit (5)
- # ring-swagger (3)
- # rum (1)
- # shadow-cljs (113)
- # slack-help (9)
- # spacemacs (16)
- # specter (4)
- # sql (14)
- # vscode (2)
- # windows (3)
- # xtdb (12)
What is a proper way to provide a different implementation of a boundary in dev versus prod?
You give the prod and dev implementations different keywords, deriving from the same base.
Is there an example somewhere?
Thanks 🙂
I can’t think of one off the top of my head. Let me sketch one out for you.
Great I basically have a defprotocol with two implementations
Two deftypes
Okay, so you’d write init-key
methods for both of them:
(defmethod ig/init-key ::dev [_ opts]
(->DevType opts))
(defmethod ig/init-key ::prod [_ opts]
(->ProdType opts))
And then in your duct_hierarchy.edn
you’d put something like:
{:app.foo/dev [:app/foo]
:app.foo/prod [:app/foo]}
So they derive from the same parent.
Then you put the dev one in your dev profile, and the prod one in your prod profile.
And refer to it using the parent keyword, e.g. #ig/ref :app/foo
.
That way the reference will choose whichever key (dev or prod) is in your configuration.
Thanks took some time to digest and implement, but works like a charm now
Cannot find an example
So I want a component to depend on an abstraction
And then provide in config what implementation of the abstraction I use