Fork me on GitHub
#clojurescript
<
2020-02-09
>
Santiago11:02:31

I’m new to CLJS and have no JS experience. I started learning CLJ directly. I’m using Lein and want to add a small JS lib to my project and use the functions included https://raw.githubusercontent.com/arhs/iban.js/master/iban.js I added this to the cljsbuild part of my project.clj

:externs ["ext/iban.js"]
:foreign-libs [{:file "ext/iban.js"
                :provides  ["ibanjs"]}
how do I use the functions now? I’m trying to replicate this https://codepen.io/kirel/pen/bGNmEjP using reagent

p-himik12:02:05

I can't really say anything about Lein at this point since I stopped using it quite some time ago. But FWIW (maybe you decide to experiment), it's very simple to use NPM libraries and JS files with shadow-cljs. You just install them or put them within your project and require them. That's it.

Santiago12:02:51

@U2FRKM4TW and then (js/isValid) ?

Santiago12:02:12

to get the isValid function, or do I need to access the object first? I installed the package with NPM and required iban

p-himik12:02:07

Just require it as ["iban" :refer [isValid]] and then use the isValid function as is.

p-himik12:02:01

If you want the function to have a better name, you can use ["iban" :rename {isValid isValidIBAN}].

p-himik12:02:56

Or just ["iban" :as IBAN] and then use JS interop: (.isValid IBAN some-iban-string).

p-himik12:02:28

This section in particular has the require convention outlined in a nice table: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

Santiago15:02:15

thank you @U2FRKM4TW I’ll try this 😉

sova-soars-the-sora17:02:41

Glad you're experimenting! good luck.

yedi18:02:07

does anyone have a comparison table for cljs routing options (theres a billion)

yedi18:02:33

i'm thinking ill probably just go with reitit, but would like to know more specifically how it compares to some others

p-himik20:02:39

Reitit has a doc that compares it to Bidi: https://github.com/metosin/reitit/blob/master/doc/faq.md

🙏 4
yedi21:02:04

oh sweet thanks

ananaa19:02:05

Hey, does anyone know a module that would enable evaluating clojurescript on browser? I am trying to create add clojurescript repl or at least single form evaluation on typescrip/react website.

p-himik20:02:41

Not a module, but an open-source app: http://app.klipse.tech/

p-himik20:02:11

Although, it calls itself plugin on its GitHub page.

ananaa06:02:03

Ya, I ran into klipse, but I was hoping for something more “raw” that would be closer to allowing me to evaluate strings as clojurescript.