Fork me on GitHub
#mount
<
2016-06-02
>
tolitius13:06:11

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

jiangts20:06:52

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

jiangts20:06:27

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

jiangts20:06:44

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

jiangts20:06:12

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

tolitius20:06:03

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

jiangts21:06:22

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

jiangts21:06:33

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

jiangts21:06:02

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

jiangts21:06:49

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!

tolitius21:06:10

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