Fork me on GitHub
#clojurescript
<
2017-08-17
>
tony.kay00:08:58

I can verify that after cleaning the source and upgrading to 0.5.13 of figwheel that it all seems to work.

briantrice01:08:03

dang. I can鈥檛 install lein-nrepl because my team uses lein-cooper: https://github.com/clojure-emacs/cider-nrepl/issues/404

briantrice01:08:05

ok, I guess I disable that locally. hum.

dehli03:08:13

is it possible to store a function in an atom? i'm trying to pass a function up from a child to its parent

noisesmith03:08:36

yes, but you should just be able to return a function from the child to the parent

noisesmith03:08:04

there's also promises (if the value only needs to be set once)

dehli03:08:32

i'm not sure i follow. where would i return the function? (this is in the context of React)

noisesmith03:08:09

oh I'm sorry, I misread

dehli03:08:56

no worries! also what i was doing just started working 馃檪

dehli03:08:08

must have been a browser cache issue

dehli03:08:24

thanks for the help!

roklenarcic08:08:20

what do you guys use to serve clojurescript apps?

martinklepsch08:08:52

@roklenarcic often just S3/Cloudfront/Route53

roklenarcic09:08:37

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

martinklepsch09:08:13

@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

roklenarcic09:08:49

I think this should do it

octahedrion10:08:15

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}

octahedrion10:08:18

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 ?

rauh10:08:40

@octo221 The vector in the first example is within an evaluated environment. (ie: tilde ~). You should add a backtick to the vector and list

octahedrion10:08:22

@rauh that's it! thanks - but why did the same macro work in a Clojure REPL without the backticks ?

rauh10:08:53

@octo221 Just a coincident, it wouldn't work in some other case, like AOT

octahedrion12:08:06

@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)

bhauman13:08:28

@octo221 also you don't need the trailing # on your variable unless it is part of the resulting expansion

octahedrion13:08:55

@bhauman oh you mean only if your macro returns something like (let [x# 5] (inc x#) ?

bhauman13:08:06

yes 馃檪

octahedrion13:08:11

got it - thanks!

bhauman13:08:06

if you expand the macro output you will see that the x# emits a unique variable name

octahedrion13:08:41

is that what's meant by 'hygienic' ?

bhauman13:08:29

this is a strategy to be hygienic, yes

octahedrion13:08:40

and the # is the same as gensym right ?

moxaj13:08:43

@octo221 mostly. Manually gensym'd symbols have the benefit of surviving multiple quote-unquotes

bhauman13:08:02

@octo221 it is helpful think of it that way, but there is more to it

octahedrion13:08:41

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 ?

bhauman13:08:38

that could help, you would have to track them, and use them where appropriate

octahedrion13:08:09

this is my third macro. The first two I wrote 5 years ago - haven't needed one all that time

octahedrion13:08:10

i don't think i understood them at all back then, I got there by trial and error

octahedrion13:08:07

hey i used gensym!

(defmacro m2 [] (let [s (repeatedly 7 gensym)] `(let ~(vec (mapcat vector s (range))) (+ ~@s))))

octahedrion13:08:43

anyway back to work - thanks for all the help!

mitchelkuijpers13:08:43

Does anyone know why this won't work?

(:refer-clojure :rename {clj->js cljs->js})

mitchelkuijpers13:08:23

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))

richiardiandrea15:08:59

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"))

symfrog15:08:51

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?

joshkh15:08:24

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?

pwrflx16:08:53

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?

pwrflx16:08:28

(I've meant reagent atoms and cursor, sorry)

thheller16:08:41

@symfrog I think bootstrap is going to be a bit problematic since it just adds things to jQuery

thheller16:08:51

it doesn鈥檛 really export anything itself

erichmond16:08:59

Is there a modern CSS library for CLJS? Or are Forest and Garden still the go-tos?

anmonteiro16:08:20

@symfrog I can repro, looking into it

anmonteiro16:08:26

so the first thing might be a bug

anmonteiro16:08:47

for the 2nd thing looks like Closure can鈥檛 process that file (maybe because of the IIFE)

anmonteiro16:08:30

I鈥檒l get to it later

bhauman22:08:44

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.

bhauman22:08:28

its mainly the constructor juggling that becomes a bit unwieldy

Roman Liutikov22:08:04

@bhauman it still can be done via JS prototypes though. I guess an example of this is in Reagent or Sablono sources

bhauman22:08:56

yes, thanks, I'm aware of that

bhauman22:08:26

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.

bhauman22:08:37

I've spent the day trying to fix the loss of React.createClass in Devcards

Roman Liutikov22:08:55

Well, createClass thing lives in its own package now create-react-class or something, which I believe is already on CLJSJS

bhauman22:08:48

yes, but for how long... and its not reliably backwards compatible to React 14 like extending React.Component is

rgdelato22:08:15

I agree that a utility lib would be helpful here, but I'm unfortunately not aware of any

anmonteiro23:08:10

@bhauman I鈥檓 sure goog.object has a bunch of useful stuff

rgdelato23:08:28

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 [] ,,,)})

bhauman23:08:46

@rgdelato that looks reasonable, it would also be interesting to explore a function that adds a constructor to extend-type

bhauman23:08:51

perhaps the above is more idomatic

bhauman23:08:46

maybe a primitive can help with that if we use extend-type?

bhauman23:08:35

nah extend type isn't going to help

bhauman23:08:42

probably would want to break this down into class and defclass would just name it.

bhauman23:08:19

actually I've written all the code for this already

rauh05:08:12

Do you have a link for that?