I was creating a wrapper for a JavaScript webrtc library and the library object has a lot of mutable fields
So my idea was to have a piece of plain data that held the configs and to put it in a mount atom
And everytime that config changed I'd update the mutable object fields
Basically it's to help me not litter my code with set! :P
> that held the configs
@jiangts: you mean that would refer to config values as: (config :some-prop)
?
ah, so for example the javascript library wants me to set connection.socketURL = <some_url>
and connection.onstream = function(stream) {...}
what I want to do is have a config for the connection
object that looks like
{:socketURL "<some_url>" :onstream (fn [stream] ...)}
so I'd store this map in an atom, and every time I swap!
, I want to automatically update the fields on the mutable connection
object using an atom watcher and set!
I might be missing something but why not have a config
state that would be used in this connection
map:
{:socketURL (config :some-url) :onstream (config :on-stream-fn)}
then when you:
(mount/stop #'app/config)
(mount/start #'app/config)
this map would be pushing new values out