This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aleph (6)
- # announcements (2)
- # babashka (8)
- # beginners (121)
- # calva (7)
- # cider (7)
- # clj-kondo (25)
- # clojure (167)
- # clojure-android (1)
- # clojure-italy (1)
- # clojure-sweden (1)
- # clojuredesign-podcast (2)
- # clojurescript (11)
- # community-development (33)
- # cursive (23)
- # data-science (1)
- # datascript (11)
- # datomic (7)
- # emacs (12)
- # events (1)
- # fulcro (15)
- # graalvm (3)
- # hoplon (1)
- # instaparse (1)
- # malli (12)
- # off-topic (1)
- # planck (3)
- # re-frame (5)
- # shadow-cljs (61)
- # test-check (2)
Is there any way to conditionally decide how to add some code to a ClojureScript macro? I want to add some debugging info to some
defn vars, but only on development. I was thinking about using the
js/goog.DEBUG var, but I found that on macro expansion time I can't access that var...
Writing a macro to write the
defn, for example.
The thing is, as macros must be written in Clojure, I'm not seeing a way to use some ClojureScript var to conditionally use on my macro...
(I don't even know if it is possible, to be honest)
Ah, so you don't want to replace
defn, you want just change the body passed to it conditionally, right?
you can test for advanced mode compilation in your macro: https://github.com/binaryage/cljs-oops/blob/master/src/lib/oops/config.clj#L21-L23
Also I'm not sure but you could probably still use
js/goog.DEBUG, just in CLJS and not during macro expansion. Because of DCE, the branch that couldn't be reached in runtime should be removed.
Great, I'll probably go through the
js/goog.DEBUG route. I completely forgot that it would be dead-code eliminated 🙂
I'm trying to understand cljs.js/eval a bit better, and trying to figure out if there is a way for me to have some communication between pieces of code that run within eval, and outside. So, I'm trying to setup some onClick handles on a hiccup component that is saved to disk, but later dynamically loaded and evaluated to make the onClick handles actually functions. When these functions are called, I want them to be able to communicate with the surrounding code. Is there any way of accomplishing this? What I've tried so far:
• Keep track of compiler state and eval a "shared" function, but it's not the same function anymore, so any references are broken, so it won't work for me
• Started looking into using
load-analysis-cache! but I'm afraid it would suffer from the same problem as above, would be executed in a new scope
Any other ideas that could help me?