This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-11
Channels
- # aws (2)
- # babashka (11)
- # beginners (107)
- # calva (6)
- # cljsrn (18)
- # clojure (180)
- # clojure-australia (6)
- # clojure-europe (54)
- # clojure-losangeles (9)
- # clojure-nl (4)
- # clojure-uk (13)
- # clojureladies (1)
- # clojurescript (57)
- # clojureverse-ops (1)
- # consultantsdirectory (1)
- # cursive (48)
- # datomic (11)
- # defnpodcast (3)
- # degree9 (1)
- # deps-new (5)
- # depstar (21)
- # docker (2)
- # fulcro (15)
- # helix (32)
- # kaocha (1)
- # lsp (21)
- # malli (15)
- # meander (15)
- # news-and-articles (2)
- # nextjournal (1)
- # off-topic (42)
- # pathom (3)
- # podcasts-discuss (1)
- # polylith (73)
- # protojure (1)
- # re-frame (43)
- # reagent (1)
- # releases (1)
- # restql (1)
- # schema (1)
- # sci (1)
- # shadow-cljs (23)
- # spacemacs (7)
- # sql (5)
- # tools-deps (42)
- # vim (15)
- # xtdb (3)
i was just experimenting with a quickstart clojurescript project, adding just an str
(clojure.core) function to the code
created 96K compiled JS file..
did any one here tried to cut down the clojurescript runtime part after compiling or is there already a way for that?
solved the size issue using google closure library, instead of using clojure str/other core functions used the google closure counter part, now the size is 1 KB (566B gzipped) my intention was creating a small loading script before loading my re-frame app (loaded via iframe) starting to love clojurescript & the ecosytem of tools ❤️
How do you deploy a gzipped js? Asking as a complete newbie... so please be patient
Normally gzip option is set in the server (like Nginx) and Server streams compressed content to browser and then browser will decompress it
@renlinx you will experience a sunk cost in order to support all of the Clojure machinery, but it doesn’t grow linearly from there, no need to worry that much about it.
Hello i am trying to get a distance from the client to a div because i want to track the x,y coordinates of the mouse inside said div. So i am trying to use that to find an offset to clientX and clientY. I've been trying different values to get offsets but with no luck yet. (fn [event] (-> event .-target .-getBoundingClientReact .-left)) and (fn [event] (-> event .-target .-getBoundingClientReact .-top)) has not worked. I am a bit of a novice in cljs, so would love to get some feedback on what i am doing wrong
This code is by the way written on a :onClick inside the div element
• getBoundingClientReact
- replace "React" with "Rect"
• .-
is used to get a field, but you need to call a function there - remove -
i think i just misspelled it here, but i still have the same issue. When i try to console log it, i get back a "lambda [event]". I am expecting to get an integer?
Works just fine for me:
> (-> js/document (.querySelector "div") .getBoundingClientRect .-height)
948
[:div
{:ref (fn [e] (when-not (nil? e)
(let [rect (.getBoundingClientRect e)
left (.-left rect)
right (.-right rect)
top (.-top rect)
bottom (.-bottom rect)
]
;; do something useful here
)))}]
That won't work in the described desired scenario: "track the x,y coordinates of the mouse inside said div".
Once the bounding box coordinates are there you could calculate the offset using clientX and clientY (unless I am not understanding the issue). You could store the bounding box details in an atom, then use the onClick event to get the clientX and clientY coordinates and map them onto the bounding box?
Getting the bounding client rect of a (.-target event)
should be no worse than your approach, even if it happens on every mouse move.
Yeah it seemed like i was console logging as you mentioned @U2FRKM4TW. Works as intended now. Thanks for the help guys!
i put the console-log inside the fn instead
I'm considering https://github.com/metasoarous/oz
And you can always use Vega without any wrappers via interop. I do just that, and it works just fine.
I usually use D3 via interop and start by copying some snippets I created at https://rollacaster.github.io/hiccup-d3/
Cool! I did not know vega used d3
Has anyone had any issues with the Google Closure compiler and the tick.alpha.api library? I am simply invoking this function: (tick/format (tick/date-time)), and it works fine in the dev environment, but does not work in the optimized build. I'm familiar with objects and declaring externs, but I have never come across functions from third-party libraries not working. In the optimized build the error says: Uncaught TypeError: http://this.Th is not a function main.js:1428 at ZonedDateTime.uP.yd (main.js:1428) at KS (main.js:1424) at Instant.hP.yd (main.js:1427) at KS (main.js:1424)
Seeing how there are Instant
and ZonedDateTime
in the stack trace, the issue is probably with this library, that is a transitive dependency of tick
: https://github.com/henryw374/js-joda
Either way, sounds like it would be better to create an issue for tick
with a minimal reproducible example.
Ok awesome thank you
we were using version 0.4.23-alpha, and shadow build
and btw we love tick so much that it's everywhere in our project, so when we ran the release build we were in for a surprise haha
ok i'll try that
Seems to be working - thank you
@U051B9FU1 I'm not quite sure why it was working before, but seems to be failing again, even with the latest version. Same error. I'll see if I can create an issue and reproduce it
e.g. in this case:
(deftest with-out-str-test
(async done
(-> (nbb/load-string "[(with-out-str (println :hello))
(with-out-str (prn :hello))
(xwith-out-str (print :hello))]")
(.then (fn [val]
(is (= [":hello\n" ":hello\n" ":hello"]
val))))
#_(.catch (fn [err]
(prn (str err))))
(.finally done))))
If I didn't put the .catch
there, the test suite just seems to pass and the error would go unnoticed.I've never dealt with such tests but FWIW I have two thoughts:
• It should be possible to create an alternative for async
that would test if the returned value is a promise and, if so, would automatically add (.catch ...)
• The unchandledrejection
event (https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) is dispatched when a promise without a catch errors out. Perhaps, it could be leveraged here.
I had a stab at an alternative a while ago https://github.com/henryw374/Cljs-Async-Timeout-Tests