Hey gals and guys, Is there a library out there that would provide this kind of switch control (same behavior as a checkbox)?
Thank you guys, I'll look into that!
If you're using React: https://material-ui.com/components/switches/ I'm sure there are many more other libraries that provide such an input.
@clement.ronzon Spectre.css can do that with (I think) just CSS: https://picturepan2.github.io/spectre/elements/forms.html#forms-switch
I’m doing some work that involves introspection on ClojureScript constructs (vars, namespaces, etc). I’ve noticed that namespace docstrings do not appear to be available in ClojureScript-land in any way. The Namespace
record includes a name and an internal ns object containing public vars, but there is no doc. Vars do have docs available to ClojureScript e.g. (-> myvar meta :doc)
.
Anyone got any thoughts about why this is? Or maybe someone has a way to access these docstrings that I’m missing? I guess they’re simply not there because namespace docstrings are not expected to be needed by the deployed application and are expected to only be relevant during development or at the REPL.
Would a PR to make these docstrings available be reasonable?
@joelittlejohn Clojure and ClojureScript are different in that CLJS does not reify vars and namespaces at runtime in your deployed application.
this information instead lives in the ClojureScript compiler
your intuition is correct in that the reason for this is to ensure that your app is slim and fast; emitting JavaScript code that added all of the namespace, var machinery and metadata would be at the least very costly in bundle size
the var
macro is an explicit mark that reads the var metadata at compile time and emits it into your code
are you analyzing code on disk, or trying to build a live CLJS application that introspects itself?
More the latter. I want to introspect on some cljs namespaces in my cljs app.
It’s interesting that the var metadata is emitted but not the namespace metadata. So I can use ns-publics
to get var info (and all metadata, including :doc), and I can use find-ns
to get namespace info, it’s just that no doc field is present.
I implemented a hack by creating my own macro to look up ns docstrings, and when the macro is compiled it emits all the relevant docstrings into its own source so they can be looked up later.
hmmm
it looks like find-ns
is bootstrap only: https://cljs.github.io/api/cljs.core/find-ns
so it's quite different than var
and ns-publics
which are macros that emit data from the analyzer
I think your approach is correct: create a macro that looks up the ns info at compile time and emit it
I suppose my next question would be: could we have a function, e.g. ns-meta
that does exactly the same thing? (just like ns-publics
, ns-imports
, ns-interns
)
Well, I suppose we’re unlikely to start adding new cljs-specific introspection functions to the core for this.
yeah it might worth asking in #cljs-dev what the best way to do this is