mount

tolitius 2016-06-02T13:19:11.000749Z

@arnout: would probably make sense @jiangts: what is the use case, i.e. why did you need watchers?

jiangts 2016-06-02T20:33:52.000755Z

I was creating a wrapper for a JavaScript webrtc library and the library object has a lot of mutable fields

jiangts 2016-06-02T20:34:27.000756Z

So my idea was to have a piece of plain data that held the configs and to put it in a mount atom

jiangts 2016-06-02T20:34:44.000757Z

And everytime that config changed I'd update the mutable object fields

jiangts 2016-06-02T20:35:12.000758Z

Basically it's to help me not litter my code with set! :P

tolitius 2016-06-02T20:58:03.000759Z

> that held the configs @jiangts: you mean that would refer to config values as: (config :some-prop)?

jiangts 2016-06-02T21:00:22.000761Z

ah, so for example the javascript library wants me to set connection.socketURL = <some_url> and connection.onstream = function(stream) {...}

jiangts 2016-06-02T21:00:33.000762Z

what I want to do is have a config for the connection object that looks like

jiangts 2016-06-02T21:01:02.000763Z

{:socketURL "<some_url>" :onstream (fn [stream] ...)}

jiangts 2016-06-02T21:01:49.000764Z

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!

tolitius 2016-06-02T21:22:10.000766Z

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