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)
a question regarding using stuart sierra's component library effectively:
I am creating an application which will make many rest calls to a different application (App-B) .
I have to pass the URL of App-B in a config file.
currently, everytime I make a request, I have to access the config file and get the URL for App-B.
I am already using the component library and was wondering if i can leverage it here.
Here is what I am thinking of doing:
Idea1:
Create an App-B record which takes accepts a URL as it's arguments and implements the Lifecycle protocol with a start and stop method.
The start
method will simply attach the URL to the component. (assoc this :url app-b-url)
The stop
method will dissoc the URL from the component.
When I am making the rest call, I will pass the instance of App-B around.
---
For this, I feel like using the components is a bit heavy. All I really need is the URL and so I can just use atoms.
Idea2:
Create a My-App record which also accept's App-B's URL.
At system start up (My-App's start time) add the URL to a pre-defined atom.
I can deref the atom whenever I'm making a rest call.
So the question is, which "Idea" is better?
Or is there an eevn simplier solution?
> Create an App-B record which takes accepts a URL as it's arguments and implements the Lifecycle protocol with a start and stop method.
If you pass the url to your new
function, no need to do anything in the start
You might consider writing a protocol with fns for each of the rest calls you make, then having your component implement it.
I will be streaming some clojure, beginner questions welcome: https://www.liveedu.tv/sveri/