Fork me on GitHub
#mount
<
2016-05-27
>
jiangts07:05:12

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

jiangts07:05:09

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]

jiangts07:05:15

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

arnout07:05:01

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

jiangts08:05:08

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

arnout08:05:10

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)

arnout08:05:10

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

arnout08:05:53

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

jiangts08:05:20

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

arnout08:05:02

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

jiangts08:05:30

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!