This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-14
Channels
- # beginners (4)
- # boot (78)
- # braveandtrue (3)
- # cider (9)
- # clara (6)
- # cljs-dev (4)
- # clojure (57)
- # clojure-brasil (1)
- # clojure-russia (99)
- # clojure-spec (20)
- # clojure-uk (40)
- # clojurescript (162)
- # component (17)
- # cursive (4)
- # datomic (21)
- # docker (2)
- # emacs (5)
- # figwheel (2)
- # hoplon (363)
- # jobs (1)
- # leiningen (1)
- # om (4)
- # om-next (5)
- # onyx (10)
- # proton (1)
- # re-frame (13)
- # reagent (13)
- # ring (3)
- # rum (1)
- # slack-help (1)
- # test-check (3)
- # untangled (7)
- # vim (24)
The question I always ask about any tool is: What value does it provide me in this situation?
For Component, the short answer is: It provides dependency injection and lifecycle management.
Lifecycle management is obvious, and it doesn't appear that's your primary concern. (Though I will point out that you could create a resource pool for accessing App-B
, and then you would need lifecycle management. This isn't necessarily a good idea, but it's not necessarily a poor one either.)
Idea1
: You've created a component that, I'm assuming, implements some protocol, and that can be swapped out with another implementation at any time.
Idea2
: You've created an implementation-dependent interaction. My-App
now must know 1) there exists a string that is a URL to App-B
, and 2) that string is contained in an atom.
My take is: If you're going to use a dependency injection scheme, make sure you're getting the full benefit from it. As far as I can tell Idea1
provides more flexibility than Idea2
.
That's not to say that you must use a dependency injection scheme. Some apps don't warrant that level of flexibility.
But, if you don't need that level of flexibility, I would do the absolute easiest thing: (defonce url "http://...")