Seems related: https://github.com/lambdaisland/kaocha-cljs/issues/25
Is there a way to detect in a macro whether the current compilation is advanced or not?
in regular CLJS you could check the compiler options I guess
@theller In CLJS I could rely on goog.DEBUG
but here it is about a macro behaving differently if it is being used in the context of an advanced build
sorry by "regular CLJS" I meant not shadow-cljs 😉
:advanced
is technically not part of the CLJS compilation and only done on the final JS as a separate step
so I don't know if the regular CLJS compiler sets anything you can check for this
the idea was that you can look at the compiler options via the cljs.env/*compiler*
atom
shadow-cljs sets something in &env
which you can check easily
(defmacro foo [bar]
(if (= :release (:shadow.build/mode &env))
`(release-code)
`(dev-code)))
@thheller Excellent, both solutions are valid (checking &env
and using cljs.env/*compiler
)*
I'll use cljs.env
as it is more general, thanks
Hi! I am stumped with a n00b question. I want to add functionality to a React Native component. I am using the PEZ repo as my starting point and need to make a TextInput component have the .focus()
method called when the custom prop :focus
is true. I am using React Native, Expo, Re-frame and Reagent. I am completely at a loss as to how to get my own text-input
component from an existing React Native TextInput component. Thanks in advance for any guidance you can give me!
Hi, guys,
I'm trying to extend a type with a protocol and I'm having problem to find out which type to use.
When I run (type my-obj)
I get #object[LocalDate]
is this the right way?
Hi there,
I am new to Clojure
I needed help converting js function to clojurescript .
I have data coming from the API which is in PascalCased map key
I am trying to get to readable state ex InventoryListNo ---> Inventory List No
Since I am used to use to js this is what I have
function splitCamelCaseToString(s) {
return s.split(/(?=[A-Z])/).join(' ');
}
splitCamelCaseToString("HelloWorld")
output: "Hello World"
This is what I created in CLJS
(defn splitCamelCaseToString [s]
(->> (str/split s #"(?=[A-Z])")
(str/join s)))
output: HelloHelloWorldWorld
Someone please tell me what am I doing wrongYou used s
twice - you're joining ["Hello" "World"]
using "HelloWorld"
as a separator.
(defn split-camel-case-to-string [s]
(.join (.split s #"(?=[A-Z])") " "))
@singhamritpal49 This is the literal translation
To do it using functions in clojure.string
(defn split-camel-case-to-string [s]
(str/join (str/split s #"(?=[A-Z])") " "))
and to use threading like you want
(defn split-camel-case-to-string [s]
(-> s
(str/split #"(?=[A-Z])")
(str/join " ")))
or
(defn split-camel-case-to-string [s]
(-> s
(.split #"(?=[A-Z])")
(.join " ")))
Thanks for your response I tried using this but I am getting empty return value
Ah I see thanks
The order of the arguments to str/join
is incorrect. Same in the next code block.