Fork me on GitHub

I'm reflecting on how fundamental namespaces are in ClojureScript


I've been digging into how hot reloading is implemented in webpack et al. and apparently when you edit a file, they have to reload every dependent module (file). because each module actually closes over the exact instance of the module that was loaded when it was instantiated


in shadow-cljs and figwheel, we just refer to the global variable which corresponds to that namespace because it's guaranteed to be unique


mindblowing how something simple as namespaces can be so effective right? 😛


They is that effective because they are so simple 😛

Ramon Rios09:11:56

Hello, have you guys tried to put a dynamic id into a [:div] or other object?


Like looping over some ids and assigning them to the element?

Ramon Rios09:11:11

I have a form for a address

Ramon Rios09:11:31

But i need to reuse it sometimes on the same part of the code

Ramon Rios09:11:58

"main address" "facturation Address"

Ramon Rios09:11:25

And i would like to render a different id for each one elements

Ramon Rios09:11:02

What i was trying to is to put an argument on the function but it did not work as i expected.


Can i see your code maybe i can help you.


Hello. Can I ask about react native here or there is another live channel for it?


@ivana there is #cljsrn


Yes, but it seems to be rare visited...


from a new user perspective it would be very nice to have a [js] one half [equiv cljs other half] page for some frameworks


there's always stuff i want to translate into cljs without much of an idea on how to go about it ;x

Mario C.15:11:30

This is a long shot but has anyone ever seen this error? Uncaught ReferenceError: currentPriorityLevel is not defined. I am using Reagent/Re-Frame. This is happening when trying to add the main app onto the <div id="app"/> root.

Mario C.15:11:54

(defn fetch-loan-button
   {:on-click (fn [e]
                (.preventDefault e)
                (rf/dispatch [:fetch-loan loan-id]))}
   "Fetch Loan"])

(defn panel
  (let [_ (rf/subscribe [:db])]
     [:input {:type "text"}]
     [fetch-loan-button "123456789"]]))

Mario C.15:11:01

This is the panel I am trying to add

Mario C.15:11:39

This is what core.cljs looks like

(defn mount-root []
  (reagent/render [fp/panel]
                  (.getElementById js/document "app")))

(defn ^:export init []
  (re-frame/dispatch-sync [:initialize-db])

Ramon Rios15:11:34

Usually it means that currentPriorityLevel is below of the function that is calling it

Mario C.15:11:27

What does that generally mean?

Ramon Rios15:11:50

(defn foo2

(defn foo
  [:h1 "hello"])

Ramon Rios15:11:40

You're calling foobut foo is after foo2 wich is calling foo

Mario C.15:11:23

Hmm that doesn't seem to be the case here though

Mario C.15:11:57

I can do this and it still happens

(defn mount-root []
  (reagent/render [:h1 "hello"] #_[fp/panel]
                  (.getElementById js/document "app")))

Mario C.16:11:53

Ah I think i know what it is

Mario C.17:11:09

@UNZALKY4V Any other reason this could be happening?

Mario C.17:11:03

I am also getting ImmediatePriority is not defined

Mario C.19:11:21

It ended up being dependency issues


Hi! What's the best way to throw an error if I manage to get myself into an infinite loop/recur? Does a timeout macro or something like that exist?


Does anyone know of a cljs function for creating a x-www-form-urlencoded payload?


roll your own, IMO it is not worth pulling in a library for simple js/encodeURIComponent usage

👍 4

I guess cljs-http.client/generate-query-string would work?


Looks like there’s also cemerick.url/map->query for anyone who’s curious (but the repo is archived on GH)


And no.en.core/format-query-params


@publicz I am not aware of such a timeout macro in Clojure's core library, but wouldn't be surprised if there was a library somewhere that had one. If you want to stop a Java thread that is an infinite loop/recur, one way would be to call the Thread.stop method on the misbehaving thread from a different monitoring thread, but there are serious warnings about that being unsafe for arbitrary JVM code, e.g. here: . If you somehow knew the thread was executing 'safe to be stopped' code, it might be safe.


Hi Andy, thanks for your reply! In this case I'm using Javascript, and it's freeezing up my browser so these bugs are a pain in the neck to debug. It would be most useful during dev/testing where I don't have proper input validation put in yet. I mean I can make a counter or timer to exit the loop, but I was curious if there are some libraries / best practices / macros there already.


Ugh, sorry, I forgot I was typing in the #clojurescript channel.


No worries, was still interesting to read 🙂 I do some java dev in my day job, so I could relate


should a CLJS linter accept (fn [e] e.message) as an alternative to (fn [e] (.-message e))? I really don't know the answer, so I'll let CLJS experts be the judge


it currently says: I don't know what e.message is. It could say: use (.-message e) but I don't know if that's always the right answer in every possible case 🙂


I would special case things in the js ns since it’s probably fairly prevalent when access things on document or window


yeah, since that's "namespaced" it always works


you would want to check whether e.message is being used as an accessor or as a method call


(e.message "foo") vs bare (prn e.message)


that's not always possible, e.g. (map e.fn xs)


in that case it would still be correct to access it as a property rather than a method call


then why would I want to check this at all?


(map (.-fn e) xs) is correct. (map (.fn e) xs) is not (it would immediately invoke (.fn e)


but maybe (.fn e) returns a function, so that <could/> be correct


it’s only the case where e.fn is being called immediately as a method that you would rewrite it to (.fn e) instead


then the original would be (map (e.fn) xs)


I can’t think of any other case where e.fn would be invoked immediately as a method other than it being in the first place of a list, from a syntax POV


but I am one voice. i’ll let others chime in now. 😄


@mario.cordova.862 did you figure it out? calling [function] or [(function)] ?

Mario C.21:11:34

@sova Yea it was a dependency issue