This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-11
Channels
- # aws (2)
- # beginners (38)
- # boot (21)
- # boot-dev (8)
- # cider (51)
- # cljsrn (3)
- # clojars (23)
- # clojure (99)
- # clojure-austin (7)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-dusseldorf (1)
- # clojure-estonia (20)
- # clojure-greece (4)
- # clojure-italy (3)
- # clojure-russia (1)
- # clojure-spec (28)
- # clojure-uk (47)
- # clojurescript (47)
- # core-logic (3)
- # cursive (9)
- # data-science (1)
- # datomic (50)
- # docs (12)
- # emacs (5)
- # fulcro (60)
- # graphql (33)
- # hoplon (8)
- # jobs-discuss (1)
- # keechma (31)
- # lein-figwheel (10)
- # leiningen (4)
- # off-topic (70)
- # om (1)
- # onyx (15)
- # pedestal (5)
- # re-frame (185)
- # reagent (14)
- # remote-jobs (8)
- # ring-swagger (7)
- # rum (17)
- # shadow-cljs (193)
- # specter (6)
- # sql (51)
- # unrepl (8)
Hi all, i have ported some JS code example from Google Maps (https://developers.google.com/maps/documentation/javascript/examples/delete-vertex-menu) to ClojureScript (https://gist.github.com/iperdomo/44911ee4ceaafa472338155edc992cbc)
it was largely inspired by some code found in Om source code, but for some reason i didn't manage to get a constructor function that have a div_
property so i workaround it by having a getDiv
function
the code works, but i was wondering if there is any improvement one can make do to it to feel more idiomatic
@iperdomo You can just write the initialization inside your ctor
function, no? Also, you can use extend-type
instead of specify!
here.
@rauh i tried to do the initialization, but some how the div DOM element was not accessible afterwards by using (.-div this)
@rauh don't we need protocols to implement or can I reference a JS constructor like js/google.maps.OverlayView
?
@iperdomo Like this:
(let [c (fn [] (this-as this
(set! this -div "foo")))]
(extend-type c Object (get-it [x] (.-div x)))
(let [i (new c)]
[(.-div i) (.get-it i)]))
I used #_
to ‘comment’ some code out, but I got a compiler error. Could be reproduced like this:
#_::foo/bar
, should that break things if foo is not a valid ns?
This throws (from the REPL) (+ 1 2 #_::foo/bar 3)
, but this is accepted: #_::foo/bar
user=> #_::foo/bar
RuntimeException Invalid token: ::foo/bar clojure.lang.Util.runtimeException (Util.java:221)
I recommend using the new clj
instead of lein repl
or boot repl
, it’s way faster and avoids having these issues
#_
reads but does not evaluate, right? I think the main implication is that the form that #_
operates on has to be syntactically valid?
is the goog/inherits
mechanism equivalent to the es6 extends
keyword? I’m asking because the rum code base seems to use the former when instantiating a component and I want to make sure I understand what’s going on
@lee.justin.m Pretty much, yeah. extends
will still be transpiled by google closure compiler unless you have language-out set to some "new JS". Though, the GCC transpiler uses a few smarter ways to extend the class
is ctor
a common clojureism? I see in in several libraries and in the clojure source
I've seen that used as shorthand for "constructor"
@lee.justin.m @manutter51 It is commonly used as “constructor”. That is true in the Java ecosystem too
This isn’t definitive, but I took a glance at rum
s usage of the ctor
name and it looks like it means “constructor” there to me.
@rauh thanks for your previous comments, i have updated a working implementation based on extend-type
instead of specify!
https://gist.github.com/iperdomo/44911ee4ceaafa472338155edc992cbc
has anyone run into caching issues with the CLJS compiler and NPM deps? in our project we can't use lein doo
without lein clean
first because for some reason the CLJS compiler does not include the NPM deps the second time
I'm not sure if this is an actual compiler problem or something to do with our own project. just wanted to see if anyone else had similar issues before I investigate further