This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-29
Channels
- # announcements (10)
- # babashka (18)
- # beginners (136)
- # calva (9)
- # cider (14)
- # clara (12)
- # clj-kondo (32)
- # cljsrn (3)
- # clojure (133)
- # clojure-europe (21)
- # clojure-nl (4)
- # clojure-uk (15)
- # clojurescript (60)
- # conjure (40)
- # cursive (12)
- # datomic (6)
- # emacs (2)
- # fulcro (19)
- # jackdaw (25)
- # jobs-discuss (3)
- # kaocha (3)
- # leiningen (5)
- # off-topic (99)
- # pedestal (1)
- # re-frame (49)
- # reagent (4)
- # ring (5)
- # rum (5)
- # shadow-cljs (53)
- # spacemacs (2)
- # sql (13)
- # timbre (2)
- # tools-deps (23)
- # vim (11)
- # xtdb (7)
what should the content-type of a .cljs file be? application/clojurescript
?
But of course neither is known by IANA, so usefulness of such media types would be limited.
js is application/javascript
but maybe it depends on the context, as js is explicitly supposed to be executed in the browser.
(it used to be text/javascript
)
Vice versa, I think. According to MDN: "Per the HTML specification, JavaScript files should always be served using the MIME type text/javascript"
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#JavaScript_types
"Even though any given user agent may support any or all of these, you should only use text/javascript. It's the only MIME type guaranteed to work now and into the future."
Which makes sense, given that application
is more generic and is intended to be used for binary data.
ah good, thanks for this!
When compiling a self-hosted clojurescript program with several macros, the compiler spams me with messages starting with
WARNING: Use of undeclared Var cljs....
Should I be concerned?@skwak22 That's not normal with self-hosted ClojureScript and macros FWIW, so it is probably worth getting to the bottom of that IMHO.
I have converted a `js` object to `clj` using (js->clj obj)
. This is what I get back: `{"foo" nil, "bar" #object[com$core$test]}` . How do I get the value of foo
and bar
?
(js->clj v : keywordize-keys true)
Can someone suggest me a good Mark Down Editor which can be easily integrated with cljs? If possible can you give me some examples also about how to use it. A bit new to Clojure.
Hi, Is this expected behavior?
cljs.user=> (def p (promise))
WARNING: Use of undeclared Var cljs.user/promise at line 1 <cljs repl>
Execution error (TypeError) at (<cljs repl>:1).
Cannot read property 'call' of undefined
Ah. OK. Thanks!
You can access the Promise constructor with js/Promise
, more info at https://clojurescript.org/guides/promise-interop
I’m trying to copy text to clipboard from a cljs app, but I’m getting undefined on (js/navigator .-clipboard)
. Am I trying to access this incorrectly?
-> is not an operator for all x
(-> x)
is identical to x
you’re right I don’t need that, I’m just moving things around. dropping the ->
gives the same result
Don't have the cljs repl handy, but there's multiple things here: writeText
returns a promise and also requires a permission from the user. So in theory your code should look something like this (-> js/navigator .-clpboard (.-writeText "foo") (.-then (fn [e] (.log js/console e))
So this is what I see in the console when running (-> js/navigator .-clipboard (.writeText "foobar"))
you spelled clpboard differently than the example
It seems to just be clipboard. When I print the js/navigator
object there are other keys such as language
languages
, clipboard
etc.
But (js/console.log (-> js/navigator .-languages) (-> js/navigator .-clipboard))
returns the languages
and clipboard
is undefined
this is the MDN for reference https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard
and the compatibility table https://developer.mozilla.org/en-US/docs/Web/API/Navigator
yeah - I was just "sharing my work" that I checked that
I think this error TypeError: undefined is not an object (evaluating 'navigator.hi.Qi')
is telling me that clipboard
and writeText
are being renamed. Trying to figure out why that is.
variables will get renamed under advanced compilation
you may be able to do the following:
(def write-text
(-> js/navigator
(goog.object/get "clipboard")
(goog.object/get "writeText")))
(write-text "foobar")
you may have to require goog.object
Was able to finally call writeText
using the above (thank you), but got an illegal invocation error 😕. I guess I need to find out why (-> js/navigator .-any-other-property)
seems to work but (-> js/navigator .-clipboard)
is undefined (I’m assuming because of the rename).
This is a guess but I think maybe there is a whitelist of properties that don’t get renamed at compile time, and clipboard
needs to be added. Not familiar enough with the compilation process though
you can whitelist properties using externs, https://clojurescript.org/guides/externs
but that doesn't seem like it would fix the Illegal Invocation error
it seems like the Illegal Invocation has something to do with the this
binding for the function
https://stackoverflow.com/questions/8904782/uncaught-typeerror-illegal-invocation-in-javascript
maybe something like:
(def clipboard
(-> js/navigator
(goog.object/get "clipboard")))
(def write-text (.bind (goog.object/get clipboard "writeText")
clipboard))
Having some trouble generalizing the new webpack support from the react example. What would the require and usage look like for a library like sjcl, for example: https://stackoverflow.com/questions/16752924/good-stanford-javascript-crypto-library-sjcl-examples-js-cryptography ?
hmm... never mind. I think I was overcomplicating it. seems to be working the way I (should have) expected.