This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-13
Channels
- # admin-announcements (1)
- # beginners (10)
- # boot (15)
- # cider (9)
- # clara (195)
- # cljsrn (24)
- # clojars (20)
- # clojure (46)
- # clojure-android (1)
- # clojure-germany (15)
- # clojure-greece (16)
- # clojure-nl (1)
- # clojure-russia (13)
- # clojure-spec (28)
- # clojure-uk (44)
- # clojurescript (104)
- # clojurex (1)
- # component (7)
- # css (2)
- # cursive (27)
- # datomic (92)
- # dirac (12)
- # emacs (5)
- # lambdaisland (3)
- # lein-figwheel (36)
- # mount (87)
- # off-topic (8)
- # om (102)
- # om-next (3)
- # onyx (30)
- # pedestal (3)
- # re-frame (26)
- # reagent (20)
- # robots (4)
- # specter (18)
- # spirituality-ethics (1)
- # untangled (127)
- # yada (11)
has anyone had the need to update a component in place. I have a situation where I created a component that connects to a third party api and holds an auth token that expires in 24 hours. So I need to update that token periodically.
this is an example of how my component looks:
(defprotocol Authentication
(authenticate [this]))
(defrecord QBaseAPI [username password app-token]
Authentication
(authenticate [this]
(let [ticket (-> (auth username password) :body xml->ticket)]
(assoc this :ticket ticket)))
component/Lifecycle
(start [this]
(authenticate this))
(stop [this]
(assoc this :username nil :password nil :app-token nil :ticket nil)))
(defn create-qbaseapi-component
[cfg]
(let [username (:username cfg)
password (:password cfg)
app-token (:app-token cfg)]
(->QBaseAPI username password app-token)))
I’m working on something similar right now, actually. The model I’m trying to implement involves a worker being spawned at start to refresh the state, with the component being derefable to yield the state.
this (https://github.com/hiredman/songs-of-future-past/blob/master/src/com/manigfeald/sofp/history.clj#L51-L97) extremely gross code spawns a worker that writes to some atoms periodically