This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (4)
- # asami (38)
- # babashka (20)
- # beginners (188)
- # cider (1)
- # clara (11)
- # clj-kondo (103)
- # cljs-dev (15)
- # cljtogether (1)
- # clojure (138)
- # clojure-australia (5)
- # clojure-europe (33)
- # clojure-france (1)
- # clojure-losangeles (5)
- # clojure-nl (4)
- # clojure-norway (11)
- # clojure-serbia (3)
- # clojure-uk (11)
- # clojurescript (45)
- # community-development (3)
- # conjure (22)
- # core-async (18)
- # datomic (44)
- # defnpodcast (4)
- # deps-new (1)
- # depstar (49)
- # events (2)
- # fulcro (33)
- # girouette (2)
- # honeysql (37)
- # jackdaw (5)
- # jobs-discuss (16)
- # kaocha (3)
- # leiningen (4)
- # lsp (77)
- # malli (55)
- # membrane (4)
- # off-topic (61)
- # polylith (5)
- # quil (5)
- # reagent (33)
- # reitit (12)
- # remote-jobs (1)
- # reveal (4)
- # rewrite-clj (2)
- # sci (16)
- # shadow-cljs (22)
- # sql (1)
- # test-check (27)
- # tools-deps (44)
Hello There, [Clojure Newbe] I need help with this function, I have function in cljs for react frontend, it renders list of item from keys. I want to use if statement to check if key exists but when I use this following code to log the if statement , it by passes the if statement. Please Help! 🙂
(defn parse-list [data] (map (fn [[k v]] (if (k = "Yesterday") (println "found")) ($ List (name k)) data))
also, looks like you are missing the end parentheses and looks like data should be moved out of the current parentheses
Can someone with a better understanding of the "why"s of Clojurescript answer this for me?
As a fairly new CLJS user, I'd expect to have the browser and JS APIs fully available to me, but after some research today I discovered that the
document.cookie API seems to be read-only in CLJS.
In vanilla JS you can both read and set a cookie with the same API:
And while I CAN read cookies with JS interop ...
document.cookie // gets cookies document.cookie = "key=value" // sets a new cookie
... if I want to set a cookie, I have to require a separate module to do so:
js/document.cookie ;; gets cookies
So anyway ... what gives?
(ns some-namespace) (:require [goog.net.cookies]) (.set goog.net.cookies "key" "value")
It's not the biggest problem in the world or anything, but it's got me wondering if there are other areas of JS <-> CLJS interop where I'm going to encounter similar situations.
https://cljs.info/cheatsheet/ check out the js-interop section for getting and setting
that being said, those goog libs are a really nice set of libs that if they offer stuff it can really help you
Cool, I appreciate it @dpsutton!
I'll experiment with
set! and see if I can get something working just so I can deepen my knowledge on the subject.
Apparently, you can also do it like this:
I'm not sure whether there's documentation for such usage, but the implementation explicitly allows it.
(set! js/document -cookies "key=value")
. in this case, as in a regular get operation, works coincidentally and not deliberately. People recommend against using
. in such scenarios but it also won't stop working.
I'm referring to the use of macros like
defstyled. I'm looking for something that will fit in nicely with the hiccup in Reagent.
It works really well with reagent: https://dvingo.github.io/cljs-emotion/#!/dv.cljs_emotion.reagent_cards see the last card on that page for an example that doesn't use defstyled
And for the mobile-oriented styling I use some custom routines that help me to maintain CSS for portrait/landscape/fullscreen orienations. It's on top of garden.
Finally got around to aligning w/ the latest Closure Compiler and a more recent snapshot of Google Closure Library
if you're comfortable using ClojureScript directly via git deps - please give it a spin
I'm noticing that Figwheel Main fails at the beginning due to the goog/log changes. It's complaining about the wrong number of arguments passed. It successfully compiled my app, including with the new npm require syntax, but when trying to recompile for hot load it hangs. And the behavior is the same without the new syntax.
What I'm struggling with right now is that the prod build with the master branch was 3MB, which is insane and was ~590KB before testing master. Now even going back to the latest stable it's still 3MB.
I cleaned out all of my NPM deps and previous build just to make sure it's clean and no change.
The 3MB is with building through figwheel-main (latest stable, not my changes). Building the prod build straight through CLJS it's 600.5KB, which is in line with the previous ~590.
Using the new require syntax with master the dev and prod builds are both 600.5KB
All of those are not gzip'd. Gzip'd on master branch with the new require syntax and regular CLJS prod build is 100.74KB. I have no clue what happened with the sizes earlier, but at least it's back on track now. Whew.