This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-17
Channels
- # arachne (1)
- # beginners (42)
- # boot (4)
- # cider (28)
- # clara (9)
- # cljs-dev (149)
- # cljsrn (5)
- # clojure (185)
- # clojure-austin (2)
- # clojure-dusseldorf (4)
- # clojure-italy (14)
- # clojure-norway (1)
- # clojure-russia (18)
- # clojure-spec (35)
- # clojure-uk (36)
- # clojurescript (78)
- # core-async (6)
- # data-science (20)
- # datomic (48)
- # emacs (1)
- # fulcro (2)
- # garden (4)
- # hoplon (47)
- # jobs (5)
- # jobs-rus (1)
- # leiningen (2)
- # lumo (12)
- # off-topic (8)
- # om (8)
- # onyx (39)
- # parinfer (19)
- # re-frame (100)
- # reagent (15)
- # ring-swagger (1)
- # sql (8)
- # vim (1)
- # yada (20)
I can verify that after cleaning the source and upgrading to 0.5.13 of figwheel that it all seems to work.
dang. I can鈥檛 install lein-nrepl because my team uses lein-cooper: https://github.com/clojure-emacs/cider-nrepl/issues/404
ok, I guess I disable that locally. hum.
is it possible to store a function in an atom? i'm trying to pass a function up from a child to its parent
yes, but you should just be able to return a function from the child to the parent
there's also promises (if the value only needs to be set once)
i'm not sure i follow. where would i return the function? (this is in the context of React)
oh I'm sorry, I misread
what do you guys use to serve clojurescript apps?
@roklenarcic often just S3/Cloudfront/Route53
using leinigen how do I pass build profile id to code? Like if the code was compiled using release build it should do X, else Y
@roklenarcic you can use something like closure defines or a macro that reaches into environment variables. The CLJS compiler doesn鈥檛 really know about Leiningen/Boot profiles/configurations
@roklenarcic here鈥檚 a guide for using :closure-defines
https://www.martinklepsch.org/posts/parameterizing-clojurescript-builds.html
I think this should do it
I have a CLJS compile problem with a macro I'm trying to write:
(defmacro tm1 [xp]
(walk/postwalk
(fn [x#]
(if (seqable? x#)
`(~(if (vector? x#) vector list) ~@x#)
x#
))
xp))
... if I use this macro from another ns like this: (tm1 [:a [1 2 3] (:x)])
then I get the error: failed compiling constant: clojure.core$vector@54e8f10a; class clojure.core$vector is not a valid ClojureScript constant. {:constant #object[clojure.core$vector 0x54e8f10a "clojure.core$vector@54e8f10a"], :type clojure.core$vector}
but if I write
(defmacro tm1 [xp]
(walk/postwalk
(fn [x#]
(if (seqable? x#)
`(vector ~@x#)
x#
))
xp))
it compiles. Why doesn't the first one compile ?@octo221 The vector
in the first example is within an evaluated environment. (ie: tilde ~
). You should add a backtick to the vector
and list
@rauh that's it! thanks - but why did the same macro work in a Clojure REPL without the backticks ?
@rauh ahah now I see why: the first one returned unquoted vector
and list
, which were evaluated because they were in a ~
, which means they returned the function objects they referred to, and it happens that in a Clojure REPL you can evaluate an expression like (#object[...] 1 2 3)
(presumably the object returns itself)
@octo221 also you don't need the trailing #
on your variable unless it is part of the resulting expansion
@bhauman oh you mean only if your macro returns something like (let [x# 5] (inc x#)
?
got it - thanks!
is that what's meant by 'hygienic' ?
and the #
is the same as gensym
right ?
@octo221 mostly. Manually gensym
'd symbols have the benefit of surviving multiple quote-unquotes
say I wanted to generate a let binding of a million symbols (let [a# 0 ... z# 25] ...)
i'd use gensym to make them all ?
this is my third macro. The first two I wrote 5 years ago - haven't needed one all that time
i don't think i understood them at all back then, I got there by trial and error
hey i used gensym!
(defmacro m2 [] (let [s (repeatedly 7 gensym)] `(let ~(vec (mapcat vector s (range))) (+ ~@s))))
anyway back to work - thanks for all the help!
Does anyone know why this won't work?
(:refer-clojure :rename {clj->js cljs->js})
I am using this in a cljc file where I want to define this:
#?(:clj (def clj->js identity)
:cljs (def clj->js cljs->js))
very cool stuff you can do nowadays, I wanted to thank the cljs contributors for this:
(ns cljs-lambda.js-build
(:require "os" "fs" "path" "archiver"))
I am attempting to use the [email protected] module, it seems that it is not indexed under bootstrap
by cljs.closure/handle-js-modules
. It is, however, indexed under bootstrap/dist/js/bootstrap
, but when I try to (require ["bootstrap/dist/js/bootstrap"])
, I get a Assert failed: cljs.analyzer/foreign-dep? expected symbol got "bootstrap/dist/js/bootstrap"
error. I have tried various other paths (e.g. "bootstrap/js/modal") with both 1.9.908 and master with the same result. Does anyone know how this can be resolved?
given the newest release of clojurescript, i should be able to include d3 from npm and use it like a goog module, something like (d3/scale some-args)
, right? or are we still using js interop syntax?
Is anyone using spec with clojurescript? My main question would be, how do you spec functions that are expecting react atoms or cursors as parameter?
@symfrog I think bootstrap
is going to be a bit problematic since it just adds things to jQuery
@erichmond I use Garden
@symfrog I can repro, looking into it
so the first thing might be a bug
for the 2nd thing looks like Closure can鈥檛 process that file (maybe because of the IIFE)
I鈥檒l get to it later
@anmonteiro great, thanks!
I'm wondering if there is a CLJS convenience library to help with ES6 class semantics, especially extension, given that this is going to be the only path for defining React lifecycle components without a React wrapper.
@bhauman it still can be done via JS prototypes though. I guess an example of this is in Reagent or Sablono sources
I'm just thinking about how this is going to be something people encounter earlyish because FB says use ES6 classes to do React and while we can do this, it's not particularly fun. But we do have some awesome React wrappers.
Well, createClass thing lives in its own package now create-react-class
or something, which I believe is already on CLJSJS
yes, but for how long... and its not reliably backwards compatible to React 14 like extending React.Component is
I agree that a utility lib would be helpful here, but I'm unfortunately not aware of any
@bhauman I鈥檓 sure goog.object
has a bunch of useful stuff
so what would your ideal CLJS ES6 class syntax look like? Would it be something in this ballpark?
(defclass home-page Component
{:constructor (fn [] ,,,)
:render (fn [] ,,,)})