are there any examples of adding watchers to clojurescript mount state?
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]
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
here https://github.com/tolitius/mount/blob/master/doc/clojurescript.md#managing-state-in-clojurescript
@jiangts: when looking at the source, I think it is not implemented yet?
I see: looks like mount states aren't plain old atoms?
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)
@jiangts: true, though it does use plain old atoms in its implementation 🙂
But, maybe @tolitius wants to add "official" support for this 🙂
that'd be preferable, but I'll use the workaround for now. Thanks!
@jiangts: not sure if the workaround works in CLJS though, so I am curious to know your results 🙂
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!
Nice!