This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-01
Channels
- # announcements (3)
- # babashka (1)
- # beginners (29)
- # calva (3)
- # cider (5)
- # clojure (17)
- # clojure-europe (9)
- # clojurescript (31)
- # conjure (2)
- # cursive (14)
- # datomic (51)
- # deps-new (4)
- # honeysql (8)
- # introduce-yourself (1)
- # lumo (8)
- # malli (28)
- # missionary (1)
- # off-topic (20)
- # pathom (2)
- # polylith (22)
- # practicalli (10)
- # reagent (3)
- # reitit (6)
- # ring (2)
- # schema (2)
- # shadow-cljs (25)
- # spacemacs (3)
It’s a commercial product, and I have no affiliation with it but it is pretty good IMO; I’ve used it years ago, not recently but I assume it’s still good https://www.highcharts.com (it’s a JS-library, but as far as I recall, the API is quite data-driven so it feels almost “idiomatic” to use from CLJS)
visual clojure functions would be sweet.
Perhaps something like this could be used: https://github.com/helins/dsim.cljc#animation Not a very direct way, but a way.
you could use d3… or an animation library like gasp. gasp timelines as a clojure dsl have been on my mind for quite a while.
@U9VP9VCE6 I can only find GSAP at https://greensock.com/gsap/, not gasp. Do you maybe have a link?
Hi folks. I'm looking for a clojurescript example that does not use react or any framework like that, that modifies the DOM of a web page. Is that possible with pure clojurescript?
Since it's possible with pure JS, it's also possible with pure CLJS.
The examples won't be that different from what you see in JS, but you can use some built-in functionality like clojure.browser.dom
and maybe shadow.dom
if you use shadow-cljs.
https://developer.mozilla.org/en-US/docs/Web/API Direct interop is your friend
i use this light wrapper from karsten schmidt… the create doom from hiccup style is a great time saver https://github.com/thi-ng/domus/blob/master/src/core.org
Harrumph. Is there a problem with vector destructuring in macro expansions?
(defmacro with-mxr [& body]
`(hx/fnc []
(let [[_ set-state#] (hooks/use-state 0)]
(rn/set-state-record ~'me set-state#)
[email protected])))
The error is about the left side of the LET binding not being a symbol or map:
------ ERROR -------------------------------------------------------------------
File: /Users/kennethtilton/dev/matrix/cljs/mxnative/src/myapp/build.cljs:45:43
--------------------------------------------------------------------------------
42 | :rx-dom (cFonce (with-par me
43 | (mkrx
44 | {:name :root
45 | :rendering (cF (with-mxr
-------------------------------------------------^------------------------------
Syntax error macroexpanding cljs.core/let.
Call to cljs.core/let did not conform to spec.
-- Spec failed --------------------
([[myapp.mxr-gen/_ set-state__48094__auto__] ...] ... ...)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
should satisfy
simple-symbol?
or
map?
Am I missing sth simple?Your _
gets a namespace because of the syntax quote above.
Try evaluating
`(let [_ nil])
and you'll see the same thing.
To fix that, you can replace _
with
~'_
Brilliant. Thx! I thought I had tried using a throwaway getter#
instead of the _
placeholder, but I guess not. And I did think I saw it complaining about the let
binding, but mebbe that was down stream, Thx again. 🙏
How does CLJS handle this?
(ns foo.script
(:require ["fs" :as fs]))
(println (count (str (fs/readFileSync "script.cljs"))))
Does it create a "real" namespace for fs
or is fs
just the fs object from the library itself? And is fs/readFileSync
then translated into an object lookup in this library, or is there a "real" namespace with a readFileSync
function created behind the scenes?
It seems like it's doing something like the latter:
cljs.user=> (str (fn [] (fs/readFileSync "script.cljs")))
"function (){\nreturn cljs.user.node$module$fs.readFileSync.call(null,\"script.cljs\");\n}"
Tracking it here (as well): https://github.com/borkdude/nbb/issues/11
I'm doing some pretty computationally intensive work in ClojureScript with a need to mutate values in place. I decided on using volatile!
since it to me seems like the most "bare bones" wrapper around a value that's still mutable within a local scope and since thread safety shouldn't be an issue in the browser. Is there a neater way to do this? As a nonsensical example:
// JS
let a = 0;
for (let i = 0; i < 100; i++) {
a += i;
}
console.log(a);
; cljs
(let [a (volatile! 0)]
(dotimes [i 100]
(vreset! a (+ @a i)))
(println @a)
Did you consider using loop
? To steal an example from clojuredocs:
(loop [x 10]
(when (> x 1)
(println x)
(recur (- x 2))))
@borkdude Yeah, that was my first approach but it started getting out of hand when the number of variables grew, this way the compiler helps a bunch too:
(let [!enabled (volatile! true)
!min-distance (volatile! 0)
!max-distance (volatile! js/Infinity)
!min-zoom (volatile! 0)
!max-zoom (volatile! js/Infinity)
!min-polar-angle (volatile! 0)
!max-polar-angle (volatile! js/Math.PI)
!min-azimuth-angle (volatile! (- js/Infinity))
!max-azimuth-angle (volatile! js/Infinity)]
...
)