This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-30
Channels
- # adventofcode (27)
- # ai (1)
- # announcements (2)
- # aws (66)
- # babashka (2)
- # beginners (34)
- # calva (28)
- # cider (5)
- # clj-kondo (18)
- # clojure (16)
- # clojure-europe (4)
- # clojure-norway (2)
- # clojure-uk (3)
- # clojurescript (11)
- # code-reviews (23)
- # conjure (23)
- # core-logic (1)
- # cursive (12)
- # datalevin (1)
- # datomic (9)
- # introduce-yourself (3)
- # kaocha (3)
- # klipse (4)
- # malli (42)
- # midje (1)
- # minecraft (1)
- # missionary (4)
- # music (1)
- # nextjournal (10)
- # polylith (5)
- # re-frame (2)
- # reitit (1)
- # releases (1)
- # sci (126)
- # shadow-cljs (4)
- # sql (2)
- # tools-deps (11)
Is there a way to do if ("ontouchend" in document)
in ClojureScript? The in
keyword I mean.
;; If missing and nil means the same
(let[ doc {"str-key" "str-val"
:key1 :val1
:key2 nil}]
(if (doc "str-key")
:key-found
:not-found))
(let[ doc {"str-key" "str-val"
:key1 :val1
:key2 nil}]
(if (doc :key2)
:key-found
:not-found))
;; if missing and nil don't mean, personally I would avoid it
(let[doc {"str-key" "str-val"
:key1 :val1
:key2 nil}]
(if (not= ::not-found (doc :key2 ::not-found))
:key-found
:not-found))
I think this should work:
(goog.object/containsKey js/document "ontouchend")
https://google.github.io/closure-library/api/goog.object.html#containsKeyI am having trouble getting a basic tagged literal working in ClojureSript. I put together a small reproduction here (replicated with shadow and the cljs compiler): https://github.com/dvingo/data-readers-bug-cljs it works fine with clojure - is there something obvious I'm missing?
ClojureScript reader tags are processed in Clojure. your read-it
fn isn't available in Clojure, it's ClojureScript
basically, the CLJS compiler is a Clojure program. when it reads your CLJS code, it looks up tagged literals that are registered and attempts to call the Clojure function associated with it. In this case, there is no Clojure function called hello-world.core/read-it
so it fails to compile
you can fix your example by creating a hello_world/core.clj
file with the read-it
fn, and then using :require-macros
to make sure it's included while processing your hello_world/core.cljs
file
in more complicated cases, reader tags used with compiled CLJS should emit CLJS code (like a macro) since the reader tags are executed at compile time. this is different than CLJ