Fork me on GitHub
#clojurescript
<
2021-11-09
>
borkdude09:11:02

What's the recommended way of manually printing a testsummary after calling test-vars ? I now have:

(defn print-summary []
  (t/report (assoc (:report-counters (t/get-current-env)) :type :summary)))

Asier11:11:00

Is it possible to build an Android https://developer.android.com/guide/components/services (without UI, just a background process that reads some files and sends data to the cloud) in Clojurescript + React Native? If so, which approach do you recommend?

dnolen13:11:37

@asier.galdos that's probably possible - using V8 directly is also an option

🙏 1
Ryan18:11:25

I asked in #beginners but it looks like it may be a little specific to cljs.. I'm getting an error trying to pass a namespace to public-ns at runtime:

(defn test1 [v] (ns-publics v))
Encountered error when macroexpanding cljs.core/ns-publics.
AssertionError: Assert failed: Argument to ns-publics must be a quoted symbol
It works in a clj repl but not cljs.. any clues?

Ryan18:11:50

And I know the fn does nothing, I just trimmed the actual fn to the part thats giving me fits 🙂

p-himik18:11:42

ns-publics is a macro, so it can't be used at run time. And it also makes sure that you don't pass any run time data in there by requiring you to provide a quoted symbol, like 'a. You can use ns-publics only during compilation.

Ryan19:11:26

So is there a runtime way to get a list of functions from a namespace?

p-himik19:11:56

Let's make a step back - what is the problem you're trying to solve?

Ryan19:11:03

Ok, I'm storing some hiccup with some keywords that map to custom react components, replaced at runtime by clojure.walk and rendered. The replacement map is e.g. [:question-long dq/question-long]

Ryan19:11:56

I want to dynamically generate that replacement map from function metadata. I've annotated the functions and have the function worked out to generate the map correctly with the namespace hardcoded into the function

Ryan19:11:04

was trying to make the hardcoded part more dynamic

Ryan19:11:35

other challenge is to resolve the symbol at some spot, because the hard coded map does that just fine

Ryan19:11:02

trying to prevent forgetting to keep the replacement map up to date as that namespace grows with additional components

p-himik19:11:29

You can definitely do that in compile time - create that map with a macro. But note that you'll have to put all the imports manually. Namespace aliasing will help here.

dnolen19:11:53

@rdonahue I'll just note at a high level that you should in general avoid var metaprogramming in ClojureScript for production code

dnolen19:11:31

if you are going to do it, then I would probably run a few experiments to verify that tree shaking is not impacted by such patterns

Ryan20:11:21

And here I was thinking once I ditched angular my tree shaking problems would be over 😉 I spent the day fighting react's need for every seq to have a meta :key and thought I should make these annotations work for me for a change! But advice heeded!