in clojurescript, can states be named as non-strings?
the example cljs app in https://github.com/tolitius/mount/blob/0825ad2ed085b73b7ae989b4382ce4e0376e4be3/dev/cljs/app/example.cljs
names the app.audit-log/log
state as a string like this: (js/setTimeout #(mount/stop-except "#'app.audit-log/log") 500)
@jiangts: the reason it is a string is because in :advanced
cljs compilation mode, #'app.audit-log/log
(as a "non string") would not work, since the app.audit-log
namespace will be "optimized" into something like a.b
, hence the state won't be found. whereas a string version of it will never change.
is there a reason you would need them as non strings?
ah, gotcha. I was actually hoping to conceal some of my namespaces in the resulting output
@jiangts: you mean in the logs?
err, in the final js output
I might not be following.. where is this output go to?
like, after running the :advanced
compile, a js file is produced
usually it is useful to have explicit "ns/state", to avoid confusion what comes from where
a.. ok, to minimize the js
right
how many states do you have?
a lot!
🙂
why so many? and how many is a lot?
haha, using it in clojurescript to manage all sorts of things ranging from dom event listeners to setIntervals to setTimeouts to atom watches
i'm writing a plugin javascript application where all the listeners attached to the DOM/js state need to be start-able and stoppable
a lot is maybe like, 50 or so states
but as the application grows, the # of states will likely also grow
might be an interesting mental exercise to figure out how to optimize the names. (not saying it is easily done, but still..) could you open an issue: i.e. something like "cljs: optimize state names in :advance mode"?
I'll think about it meanwhile.. js world and :advanced
mode are quite hairy
haha, yes they are! cljs is my beacon of hope in a crazy front-end world 🙂
sounds good on the issue
great, thanks