This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-15
Channels
- # aatree (1)
- # atlanta-clojurians (3)
- # beginners (112)
- # boot (4)
- # boot-dev (1)
- # bristol-clojurians (1)
- # cider (55)
- # cljs-dev (23)
- # cljsjs (1)
- # cljsrn (7)
- # clojars (24)
- # clojure (84)
- # clojure-brasil (1)
- # clojure-china (1)
- # clojure-italy (27)
- # clojure-norway (17)
- # clojure-romania (1)
- # clojure-spec (109)
- # clojure-uk (92)
- # clojurescript (94)
- # community-development (1)
- # core-matrix (1)
- # cursive (12)
- # datascript (1)
- # datomic (23)
- # figwheel (1)
- # fulcro (17)
- # hoplon (11)
- # jobs-discuss (3)
- # keechma (6)
- # lein-figwheel (4)
- # leiningen (79)
- # lumo (32)
- # mount (42)
- # off-topic (22)
- # onyx (13)
- # parinfer (30)
- # portkey (47)
- # powderkeg (1)
- # programming-beginners (24)
- # protorepl (3)
- # re-frame (16)
- # reagent (100)
- # ring-swagger (7)
- # shadow-cljs (134)
- # spacemacs (3)
- # sql (1)
- # tools-deps (48)
- # uncomplicate (1)
- # unrepl (14)
- # yada (1)
So what's the word on clojurescript 1.10*? I found out that i'd been using the preview for a while, and there hasn't been any official release notes yet
so far, nothing seems to be broken since I bumped the version, just minor issues with cljs.devtools not understanding how to format the new MapEntry type
I have a piece of code that looks like this:
(defonce main-atom
(rc/atom
[:svg {:width "100%"
:height "100%"}
[:text {:x "100" :y "100"} "waiting for data"]]))
(defn main-gui []
@main-atom)
(defonce ttl-count (atom 0))
(defonce tick-tock-a (atom (fn [])))
(defn update-text []
(let [ms (last (str (js/Date.now)))
v (mod @ttl-count 10)]
(swap! ttl-count inc)
(reset! main-atom
[:svg {:width "100%"
:height "100%"}
[:text {:x 50 :y 50} ms]
(for [y (range 100)
x (range 100)]
^{:key [x y]} [:text {:x (+ 100 v (* 10 x))
:y (+ 100 v (* 20 y))}
ms])])))
(defn js-reload [& args]
(update-text))
#?(:cljs
(set! (.-onload js/window)
(fn [& args]
(ca/log "setting up timeout")
(js/window.setInterval (fn []
(ca/log "update func called")
(update-text))
10)
(ca/log "done setting up timeout")
(rc/render [main-gui]
(.getElementById js/document "app")))))
where I try to, at 100fps, redraw 100x100 text nodes every frame
I'm only getting around 2-3 fps on my 3-year old macbook pro in Chrome.
Should I accept this as a fundamental limitation / slowness of SVG ?@lukewallace1990: try this, copy that function into clj, eval it, then eval (new-board 3)
and you should be able to see what it is outputting; the "B" probably stands for "blank" (just guessing)
@qqq A nested for
like that will be very slow since it's fully lazy. Also your :key
will have to be converted to a string "[x y]"
which is slow.
i can't even get warnings for the wrap-baz example here: https://clojurescript.org/guides/externs#externs-inference
Oh, I see somebody else is having the same problem: https://dev.clojure.org/jira/browse/CLJS-2491
Works in Clojure but not in ClojureScript:
(defn ^{:doc (:doc (meta #'defn))} doc-string-copy [a b c])
. Is there a way to accomplish this in ClojureScript?@maridonkers check the section on Special Forms: https://clojurescript.org/about/differences
You might have to use meta-fn... ClojureScript's vars are a little thinner than Clojure's. (at runtime)
If you're not getting bit by the runtime var thing, it might be something else. But that's a hunch.
var stuff should be avoided in ClojureScript except for a very small number of documented cases
@john @dnolen Was thinking about defining a wrapper function around another function and automatically copying the wrapped function's docstring. This also doesn't work:
(def ^{:doc (str "A docstring.")} doc-string-copy (fn []))
with the same exception: clojure.lang.PersistentList cannot be cast to java.lang.CharSequence
But it's not a problem not having it (only wondered if there was a workaround).No problem, I'll copy the docstring manually. Thanks for the feedback.
I believe you can do the function wrapping at macroexpansion time
don't quote me on that, may be worth looking into
Unquoting 🙂 Thanks, will check it out.
In cljs, if you use the call to goog.string.format
like this: (gstring/format "%05d" 123)
do you still need to include both:
(ns example.core
(:require
[goog.string :as gstring]
goog.string.format))
Are there docs for reify
, specify
, specify!
as they apply to ClojureScript? I'm wondering if there's a more elegant way to extend React.Component than https://gist.github.com/pesterhazy/39c84224972890665b6bec3addafdf5a
@borkdude see https://www.martinklepsch.org/posts/requiring-closure-namespaces.html
@pesterhazy Why not goog/inherits
?
@rauh, did not know that existed
I was confused because it's not in the goog.object namespace. If anyone is reading along, it's defined here: https://github.com/google/closure-library/blob/master/closure/goog/base.js#L1877
I'll give that a try, thanks @rauh
looks like @bhauman has used this method with React in devcards: https://github.com/bhauman/devcards/blob/6be51e1be7c0c9468e4d5f877aa2999bbb4ded1a/src/devcards/util/utils.clj#L27
@pesterhazy Yeah there are many ways to do it. You can even do js*
:
(let [klass (if async? js/React.unstable_AsyncComponent js/React.Component)]
(js*
"class extends ~{} {
constructor(props, context) {
super(props, context);
~{}(this, props, context, ~{});
}
}" klass init-class init-fns))
It would be nice to have a tiny library that helps folks assemble JS classes, and by extension react classes
Relying on js*
sounds dangerous
@pesterhazy I agree. FWIW, David has indicated that he sees no reason to, for example, add warnings for code in the wild that uses js*
. But yeah, it makes you wonder what might happen if js*
actually ever changed in behavior.
more instances of extending React.Component in the wild: rum https://github.com/tonsky/rum/blob/01c4eee59568334f589b424727597afe219606c4/src/rum/core.cljs#L56 and sablono https://github.com/r0man/sablono/blob/d1469ae4b3c1326338fc1e52eaa45d9c0d45c700/src/sablono/interpreter.cljc#L35
@mfikes it also changes the output version from ES5 to ES6... not sure if that's an issue anymore these days though
@pesterhazy What changes the output version?
@mfikes using class
via js*
yes, that's a 100% more elegant way of putting it 🙂
@dnolen would you suggest using goog/inherit
to extend React.Component
?
if we change js*
to only work from cljs.core
and it breaks your stuff, don’t come complaining
js*
is to ClojureScript as asm
is to C, but with non-guaranteed semantics, or even existence 🙂
sh4z: check here: https://github.com/levand/domina/blob/master/src/cljs/domina.cljs#L226
Has anyone noticed chrome opening external debug windows for service workers (I think coming from youtube), when the browser reloads after a watched recompile?
Hey all. I know clojure well and nothing about javascript - hoping someone can help me solve a problem I ran into. I wrote a library in clojurescript and compiled it into javascript. I'm trying to incorporate it into an existing react app using es6 modules. I'm having problems importing the google closure file that I generated.