Fork me on GitHub
#clojurescript
<
2023-02-11
>
mathpunk00:02:40

It's been a few years since I f'd with ClojureScript. I'm not very good with JavaScript but I do use it at work. If there's a npm module i want to f around with and I want to start it as a cljs project, what's the state of the art for doing that?

p-himik04:02:51

I'd use shadow-cljs for that. Pretty much painless interop with NPM modules.

thheller07:02:21

npx create-cljs-project foo-test
cd foo-test
npm install foo
npx shadow-cljs browser-repl
(require '["foo" :as x])
(x/fAround)

💫 2
mathpunk02:02:19

awesome, thank you!

john2x02:02:16

I'm in need of a rich, full-featured datatable library. Something like https://ag-grid.com. I'm curious if a similar library is available for Clojurescript? I understand interop is an option, but if there's a more native implementation I'd like to know.

lilactown06:02:56

for something like that, interop is the way to go. the justification to build one in CLJS is just not there if you can use one of these best in class libraries from JS

👍 2
dominicm10:02:11

You'll especially want interop for a table where performance matters. For ag grid I ended up bypassing reagents call to clj->js conversion to optimise the arguments myself.

joshcho17:02:00

I am trying to simulate a keypress. I am trying in cljs

(elem.dispatchEvent (new js/KeyboardEvent "keypress" #js {:key "a"}))
in js
document.getElementById("65").dispatchEvent(new KeyboardEvent('keypress', {key: "a"}));
and neither of them works. Not sure what is the issue here. I am using re-frame, if that makes a difference.

thheller19:02:26

(.dispatchEvent elem (new js/KeyboardEvent "keypress" #js {:key "a"}))

joshcho19:02:27

Doesn't quite work for me. I am looking for a workaround as the problem seems specific

joshcho19:02:00

Turns out the problem was I was using :on-key-press in the element to detect events, not event listener.