This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-18
Channels
- # aws (10)
- # beginners (43)
- # calva (1)
- # cider (7)
- # cljs-dev (83)
- # clojure (132)
- # clojure-dev (20)
- # clojure-europe (6)
- # clojure-greece (4)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-spec (21)
- # clojure-sweden (16)
- # clojure-uk (21)
- # clojuredesign-podcast (16)
- # clojurescript (74)
- # cursive (41)
- # datomic (7)
- # emacs (3)
- # fulcro (30)
- # graalvm (3)
- # graphql (2)
- # instaparse (1)
- # jobs (1)
- # joker (13)
- # kaocha (14)
- # off-topic (118)
- # pathom (13)
- # re-frame (5)
- # reagent (22)
- # shadow-cljs (67)
- # spacemacs (7)
- # sydney (1)
- # testing (1)
- # tools-deps (82)
- # vim (4)
- # xtdb (1)
because dash character is not a valid symbol in js names
ha, even worse!
related question: in #js {:key val}
key
is generated as a string, does that mean that accessing such object should be done via gobj/get
?
itâs especially tempting to use (.-prop-key o)
when seeing #js {:prop-key v}
in code
so maybe Clojure style names in literal js objects should be avoided, to not confuse yourself
could be nice type inference warning btw, cc @mfikes
I have a issue where a bug is only present when doing the advanced compilation. I'm using no external JS libraries, so not related to externs, but somewhere, something is working differently. I'm trying to track it down, but having to do a normal build then a advanced build slows down the workflow a bit, and only way I could confirm potential fixes. Anyone have any debugging tips for tracking down the issue?
:pseudo-names true
in compiler options might help
yeah, did that, but the error that happens is because of a data inconsistency issue that happens before, so seeing the actual names in the error didn't help too much
Error: Vector's key for assoc must be a number
but again, the error is a symptom because of another issue
oooh, that's very useful @thheller, I'm pretty sure I knoiw the issue if that's the case
@thheller you happen to sit on some resource that explain more about the potential issues?
the data inconsistency still could be related to js->clj
as the data that ends up being unexpected is being passed through js->clj
at one point
yeah, no, the problem is the value I'm expecting to be a keyword in the assoc call is nil
indeed. The problem happens before that though
yeah, trying to read and understand more about where exactly the properties would be renamed to a different format than I expect
I see. Thanks! Any ideas if macros get special attention somehow when doing advanced builds?
js->clj
can become problematic because of a potential conflict with the "fast-path" protocol dispatch. that is a property with a rather long name usually, but can be renamed to something short like x
. so if you happen to have JS data with { x: 4 }
or so running through js->clj
that may break the detection and do unexpected stuff, often ending in completely insane errors running code that usually isn't even involved.
huh, that's very good to know. I'm pretty sure your note about (.-foo x)
being renamed helped me finally found the cause of the error
Yes! That was the issue indeed. I was doing (-> p# .-props .-argv second)
and changed it to (second (goog.object/getValueByKeys p# "props" "argv"))
instead and issue fixed! Thanks a lot for the help @thheller
anybody doing clojurescript game dev?
Hey folks,
I'm trying to understand how the browser repl works in cljs. I have a cljs source file and a "build" file that compiles the source and watches for changes (following the Learning ClojureScript book).
Here are my files:
src/cljs-first-project/core.cljs
:
(ns cljs-first-project.core
(:require [clojure.browser.repl :as repl]))
(defonce conn
(repl/connect ""))
repl.clj
:
(require 'cljs.repl)
(require 'cljs.build.api)
(require 'cljs.repl.browser)
;; build the project and write it to out/main.js
(cljs.build.api/build
"src"
{:main 'cljs-first-project.core
:output-to "out/main.js"
:verbose true})
;; start a repl, watch for changes
(cljs.repl/repl (cljs.repl.browser/repl-env)
:watch "src"
:output-dir "out")
I start everything by typing rlwrap java -cp cljs.jar:src clojure.main repl.clj
I don't understand the following behaviour:
ClojureScript 1.10.520
cljs.user=> (in-ns 'cljs-first-project.core)
nil
cljs-first-project.core=> conn
WARNING: Use of undeclared Var cljs-first-project.core/conn at line 1 <cljs repl>
#object[Object [object Object]]
It raises a warning of an undeclared var and then shows the value of the var. Am I doing something wrong?
Also, the book says that the :watch
flag is supposed to automatically evaluate new cljs code I type in src/cljs_first_project/core.cljs
. When I add new stuff, I have to reload the browser in order to have the new code there. Is that expected?Quick question about Reagent:
When styling width like {:width 150}
or {:width "150px"}
it works fine, but using !important
fails {:width "150px!important"}
or {:width "150px! important"}
How should I do?
!important
would have no effect in inline styles, they already override everything else
The interesting part is, this using clojurescript
1.9.946.
and based on the error, looks like it is trying to compile itâs own ns core.cljs
but I never knew of a situation where the cljs compiler would be able to read itâs own cljs (same version)
Hi all, I've been out of actively trying clojure for a while, but have some time on my hands. What's the current state of play for the various webui frameworks? If you were starting a new project tomorrow, which would you use? Did om-next arrive? Is it still reagent, reframe, something else?
Oh, I've just learnt of fulcro. The intro sounds promising.
Oh, in fact, as I read through the fulcro docs I see "because thatâs the way it was written in Om Next, the predecessor of Fulcro. I assume David Nolen had his reasons for preferring functions/macros over "
I moved my deps order aroudn slightly & and another dep âwonâ on the transitive dep resolution
itâs an older project and was curious why it seemed I needed to to get it to continue to build
I canât actually pinpoint exactly the changelog lnie that happens, but I do remember discussion around it whewn it first happened
it was one of those âyou were never supposed to call key/val on non map entry anywaysâ
> extend to vector? maybe, but sounds like it could have scary other implications hah
I was able to bring it up to modern cljs versions though - just had to find/replace these and be carefulâŚ
for fun, those changes came with https://clojure.atlassian.net/browse/CLJS-2478 if anyone is ever stumbling over this and wonders when vectors stopped being able to have key
and val
on them
which can be seen in cases like:
(->> {:a 1}
(map (fn [e] (prn (type e)) [(key e) (val e)]))
(into {}))
cljs.core/MapEntry
{:a 1}
vs
(->> {:a 1}
(map (fn [[k v]] [k v]))
(map (fn [e] (prn (type e)) [(key e) (val e)]))
(into {}))
;; cljs.core/PersistentVector
;; #object[Error Error: No protocol method IMapEntry.-key defined for type cljs.core/PersistentVector: [:a 1]]
;; cljs.core/missing-protocol (jar:file:/.../clojurescript-1.10.520.jar!/cljs/core.cljs:316:4)
;; cljs.core/-key (jar:file:/.../clojurescript-1.10.520.jar!/cljs/core.cljs:644:1)
;; cljs$core$key (jar:file:/.../clojurescript-1.10.520.jar!/cljs/core.cljs:9010:4)