This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-29
Channels
- # announcements (6)
- # beginners (110)
- # calva (18)
- # clj-kondo (19)
- # cljs-dev (27)
- # clojars (10)
- # clojure (38)
- # clojure-art (2)
- # clojure-europe (13)
- # clojure-germany (1)
- # clojure-norway (26)
- # clojure-uk (2)
- # clojurescript (10)
- # conjure (9)
- # cursive (12)
- # data-science (3)
- # datomic (22)
- # emacs (8)
- # helix (9)
- # honeysql (18)
- # introduce-yourself (1)
- # jobs (1)
- # leiningen (8)
- # lsp (22)
- # missionary (9)
- # nbb (11)
- # off-topic (83)
- # pathom (5)
- # pedestal (4)
- # polylith (1)
- # portal (1)
- # re-frame (3)
- # reitit (15)
- # remote-jobs (1)
- # rum (4)
- # shadow-cljs (88)
- # specter (12)
- # testing (1)
- # vim (39)
Hi. I don’t quite get the use of enable-console-print!
. The docs says it binds print-fn to console.log. So does that mean, if we do not do that, the (println) messages won’t be shown?
For example, if you’re developing a web app, print messages will be shown in your REPL, but not in the browser’s devtools console if you don’t enable-console-print!
. Regardless you can still print to the console manually by using js/console.log
.
Basically without a print function set to output to the web/Node console (i.e. console.log
), print statements will not print to console 🙅
@UGC0NEP4Y enable-console-print!
is no longer required as of ClojureScript 1.10 https://clojurians-log.clojureverse.org/clojurescript/2018-10-16/1539688185.000100
Should clojure.edn/read-string
create js/BigInt
s when the number has an "N" suffix (running on Node.js target)
(type (edn/read-string "1N")) => #object[Number]
Looking at this for integers > (.-MAX_SAFE_INTEGER js/Number)
it still produces only Numbers, never BigInts. In clojure, integers with an N" suffix will create
clojure.lang.BigInt`s, and I notice that other edn parsers for javascript do the same. But clojurescript itself seems to lose precision for clojure.edn/read-string
Printing a js/BigInt
is straight forward:
(extend-protocol IPrintWithWriter
js/BigInt
(-pr-writer [n writer opts]
(-write writer (str n "N"))))
But I can't read them back in using read-string
(without losing precision anyway)There's a library called edn-data
(https://github.com/jorinvo/edn-data). Using this library, which contains a parseEdnString
function:
(def parse-edn-string (.-parseEDNString edn-data)) (type (parse-edn-string "1N")) => #object[BigInt]
we'll get a js/BigInt
.After a lot of frustrations finally I got the model how (actually, contrintuitive imho) Compojure calls middlewares, and want to share maybe the only (?) solution worked the way it shoul be 😊
(defroutes app-routes
(-> public-routes
(wrap-routes wrap-parse-params-body))
(-> secured-routes
(wrap-routes wrap-parse-params-body)
(wrap-routes wrap-authentication))
(-> mobile-routes
(wrap-routes wrap-parse-params-body)
(wrap-routes wrap-mobile-authentication))
(-> (route/resources "/")
(wrap-routes wrap-authentication)) ;; all resources are private for direct access (load from html etc.)!
(-> (ANY "*" [] {:status 404}) ;; (route/not-found {:status 404}) doesn't call wrap-authentication!
(wrap-routes wrap-authentication)))
(def handler
(-> app-routes
wrap-cookies))
PS yes, I had to wrap them all with wrap-routes
and triplicate wrap-parse-params-body
etc.