Fork me on GitHub
#clojurescript
<
2019-09-26
>
andy.fingerhut02:09:33

They should, yes.

g7s07:09:38

Is there any way to have clojure proxy functionality in cljs? I want to create an instance of a subclass of a given class. Looked around but didn’t find anything related..

purrgrammer10:09:39

I'm not sure what you are trying to accomplish but proxy is JVM-specific, there is no concept of "interfaces" in JS

g7s10:09:29

Sure but there is a concept of “classes” so it is still a valid usecase

lilactown16:09:33

you can use reify, probably

Roman Liutikov07:09:12

there’s Proxy object is JS, don’t think it works same as proxy though

ghaskins12:09:05

hello all, im struggling to understand the proper interop incantations to access this library

ghaskins12:09:17

any guidance appreciated

ghaskins12:09:54

using shadow-cljs, normally id do something like

(:require ["/foo" :as foo])
and then instantiate with
(foo/Bar. ..)

ghaskins12:09:56

but im not a javascript guy and I dont quite get how to access the QRCode class in this particular library

thheller13:09:42

did you copy the file into your classpath? the file doesn't export anything so you can't use the normal syntax to access anything

thheller13:09:12

you can probably make it work by adding module.exports.QRCode = QRCode; as the last line in qrcode.js

thheller13:09:33

and then (:require ["/some/path/qrcode.js" :refer (QRCode)]) and (QRCode. ...)

ghaskins12:09:35

everything ive tried results in errors like

qr_code.QRCode is not a constructor

manutter5112:09:28

Have you tried (new js/QRCode (.getElementById js/document "test) url)?

ghaskins17:09:59

Thanks for the reply. I think I did try that but I ended up switching to the npm-qrcode and got that working

ghaskins17:09:03

but appreciate the help

ghaskins17:09:47

(its also quite possible I didnt try that exact permutation and it might have worked, heh)

👍 4
Dan12:09:19

Is there a CLJS equivalent to how you can interpolate strings in Template Literals in ES6?

import { color } from 'demo'

const Test = `
  ${color}
`

niwinz13:09:15

I'm not aware that cljs nativelly supports interpolation in similar way as ES6, with funcool/cuerdas you have the istr macro:

(require '[cuerdas.core :as str :include-macros true])

(def foo "bar")
(str/istr "hello ~{foo}")
;; => "hello bar"

thheller13:09:36

whats wrong with just using (str "before" color "after") or so?

Dan13:09:49

Because that won't reference the color variable from the import

thheller13:09:24

hmm? of course it will?

scknkkrer16:09:10

Hey folks, have anyone developed any Hiccup implementation in Javascript ?

scknkkrer23:09:39

For anyone who suffer like us; Here is the Hiccup Notation Implementation for the Javascript! https://www.npmjs.com/package/@thi.ng/hiccup#installation Thank you to the Author !