This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-08
Channels
- # adventofcode (9)
- # announcements (5)
- # babashka (3)
- # beginners (46)
- # calva (21)
- # cider (15)
- # clj-kondo (20)
- # cljs-dev (57)
- # cljsrn (10)
- # clojure (147)
- # clojure-dev (6)
- # clojure-europe (3)
- # clojure-france (2)
- # clojure-italy (8)
- # clojure-nl (18)
- # clojure-norway (5)
- # clojure-spec (16)
- # clojure-uk (63)
- # clojuredesign-podcast (7)
- # clojurescript (65)
- # clojurex (42)
- # cursive (12)
- # datomic (10)
- # fulcro (47)
- # graalvm (102)
- # graphql (2)
- # jobs (5)
- # joker (12)
- # off-topic (33)
- # pedestal (6)
- # re-frame (6)
- # reagent (8)
- # reitit (6)
- # remote-jobs (4)
- # rewrite-clj (10)
- # shadow-cljs (86)
- # sql (45)
- # testing (4)
- # tools-deps (43)
- # vim (8)
- # xtdb (3)
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
They is that effective because they are so simple 😛
Hello, have you guys tried to put a dynamic id into a [:div]
or other object?
I have a form for a address
But i need to reuse it sometimes on the same part of the code
"main address" "facturation Address"
And i would like to render a different id for each one elements
What i was trying to is to put an argument on the function but it did not work as i expected.
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
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.
(defn fetch-loan-button
[loan-id]
[:button
{:on-click (fn [e]
(.preventDefault e)
(rf/dispatch [:fetch-loan loan-id]))}
"Fetch Loan"])
(defn panel
[]
(let [_ (rf/subscribe [:db])]
[:div
[:input {:type "text"}]
[fetch-loan-button "123456789"]]))
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])
(dev-setup)
(mount-root))
Usually it means that currentPriorityLevel is below of the function that is calling it
Fox example
(defn foo2
[foo])
(defn foo
[:h1 "hello"])
You're calling foo
but foo is after foo2 wich is calling foo
I can do this and it still happens
(defn mount-root []
(reagent/render [:h1 "hello"] #_[fp/panel]
(.getElementById js/document "app")))
@UNZALKY4V Any other reason this could be happening?
Great
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?
roll your own, IMO it is not worth pulling in a library for simple js/encodeURIComponent
usage
google closure lib does it here (not exposed as public api): https://github.com/google/closure-library/blob/289b70501738a0944f35c7049378d0c88774b515/closure/goog/dom/forms.js#L235
Looks like there’s also cemerick.url/map->query
for anyone who’s curious (but the repo is archived on GH)
@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: https://docs.oracle.com/javase/7/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html . 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
you would want to check whether e.message
is being used as an accessor or as a method call
in that case it would still be correct to access it as a property rather than a method call
(map (.-fn e) xs)
is correct. (map (.fn e) xs)
is not (it would immediately invoke (.fn e)
it’s only the case where e.fn
is being called immediately as a method that you would rewrite it to (.fn e)
instead
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
@mario.cordova.862 did you figure it out? calling [function] or [(function)] ?