mount

jiangts 2016-05-27T07:54:12.000445Z

are there any examples of adding watchers to clojurescript mount state?

jiangts 2016-05-27T07:55:09.000446Z

I'm getting the following error: could not start [#'app.example/config] due to Error: No protocol method IWatchable.-add-watch defined for type mount.core/DerefableState: [object Object]

jiangts 2016-05-27T07:57:15.000447Z

whereas the clojurescript readme has the following line: States may have watchers which is just an idea at this point, but it could be quite useful

arnout 2016-05-27T07:59:01.000450Z

@jiangts: when looking at the source, I think it is not implemented yet?

jiangts 2016-05-27T08:02:08.000452Z

I see: looks like mount states aren't plain old atoms?

arnout 2016-05-27T08:02:10.000453Z

You could hack it yourself, by adding a watcher on @#'mount.core/meta-state, or on (-> @#'mount.core/meta-state (.name your-derefable-state) :inst)

arnout 2016-05-27T08:03:10.000455Z

@jiangts: true, though it does use plain old atoms in its implementation 🙂

arnout 2016-05-27T08:03:53.000456Z

But, maybe @tolitius wants to add "official" support for this 🙂

jiangts 2016-05-27T08:04:20.000457Z

that'd be preferable, but I'll use the workaround for now. Thanks!

arnout 2016-05-27T08:06:02.000458Z

@jiangts: not sure if the workaround works in CLJS though, so I am curious to know your results 🙂

jiangts 2016-05-27T08:21:30.000461Z

it worked! The representation of @#'mount.core/meta-state is slightly different in clojurescript (so I need to dereference it yet again), but otherwise it works 🙂 Thanks!

arnout 2016-05-27T08:21:57.000463Z

Nice!