Fork me on GitHub
#clojurescript
<
2016-02-26
>
voxdolo00:02:13

ah, I see. so the cheatsheet is all CLJS, then? we have CLJ/CLJS in an uberjar that gets deployed and my issue is mostly one of timing (how to get in before jarring but after cljsbuild).

voxdolo00:02:44

I've got it mostly resolved now, but am running into unexpected issues with accessing project resources from a leinigen plugin

chrisoakman00:02:22

yes, the "build" of the cheatsheet consists of static content. nothing dynamic

currentoor05:02:44

How do I import the style sheets?

currentoor05:02:14

Or do I have to copy and paste them manually?

jimmy05:02:42

you need to do it manually

bbss05:02:17

currentoor: I used it in JS. It was actually really bad for performance, we had about 10 columns, and it is optimized for rows. Additionally it did not support touch. That was the 0.5 version and I think they had a rewrite though.

bbss05:02:03

Had 3 fps on my mbp when scrolling horizontally. Eeks. We ended up using react-infinite which performs well for our usecase. But I guess we only have 250 rows or so.

currentoor05:02:30

@nxqd, @bbss thanks!

currentoor05:02:03

also @bbss that sounds like my usecase as well, how did you include it in the project?

currentoor05:02:17

i noticed it’s not a cljsjs package

bbss05:02:18

it was not a cljs project

currentoor05:02:45

so i’d probably have to resort to a script tag?

bbss05:02:49

but if you are looking for instructions on how to use external libs I think they can be found on the cljsjs repo

bbss05:02:11

yeah script tag can work but I think you won't be able to use the closure compiler unless you provide the externs

juhoteperi06:02:51

@currentoor: One solution is to use Less/Sass compiler which can read imports from classpath: https://github.com/cljsjs/packages/wiki/Non-JS-Assets#importing-using-lesssass-compiler

currentoor08:02:43

@juhoteperi: thanks I’ll check it out.

currentoor08:02:30

well that worked splendidly!

azzikid11:02:42

hey all, i am trying to use a react component (specifically react-dropzone: https://github.com/okonet/react-dropzone) but i’m getting an error: A valid ReactComponent must be returned. i’m using reagent/adapt-react-class to transform the react object into something i can use in reagent like this:

azzikid11:02:19

(def Dropzone (js/require "react-dropzone"))
(def dz (reagent/adapt-react-class Dropzone))

(defn build-dropzone []
 [:div "test hello"
  [dz {:on-drop #(.log js/console “dropzone dropped”)} [:div “upload"]])

azzikid11:02:05

any help would be appreciated.

maio13:02:49

@azzikid: looks OK. what's in Dropzone var?

azzikid13:02:07

@maio here’s what i get printing it in the repl

azzikid13:02:11

test-zone.core=> (println Dropzone)
#object[Dropzone "function Dropzone(props, context) {
    _classCallCheck(this, Dropzone);

    _React$Component.call(this, props, context);
    this.onClick = this.onClick.bind(this);
    this.onDragEnter = this.onDragEnter.bind(this);
    this.onDragLeave = this.onDragLeave.bind(this);
    this.onDragOver = this.onDragOver.bind(this);
    this.onDrop = this.onDrop.bind(this);

    this.state = {
      isDragActive: false
    };
  }"]
nil

maio13:02:59

hm that also looks OK

azzikid13:02:45

ha. that makes this even trickier.

jaydeesimon14:02:54

What do people use to create simple line graphs in ClojureScript?

tianshu15:02:39

How to do onkeyup="foo(this)" in ClojureScript?

tianshu15:02:05

foo should be a ClojureScript function.

dnolen15:02:46

@doglooksgood: you need ^:export the function

dnolen15:02:54

then use the fully qualified (and munged) name

dnolen15:02:14

or export the name that you want

dnolen15:02:55

speaking of which :export should really take strings along with true, fixing that in master

dnolen15:02:55

actually it’s already implemented simple_smile

dnolen15:02:11

(defn ^{:export “bar”} foo [] …) should work

tianshu15:02:52

Thanks a lot!

delaguardo16:02:44

String for aliases?

pez17:02:02

I’m new to both Clojure and ClojureScript, so please bear with me if I’m having trouble even asking this question:

pez17:02:15

I’m using Secretary for routing and it has a macro defroute that takes a symbol argument (amongst others). defroute creates a function with the same name as the symbol. I would like to use the macro inside a loop and make it create named functions for each item I am looping over. But nothing I try works.

pez17:02:46

The macro is defined like so:

(defmacro ^{:arglists '([name? route destruct & body])}
  defroute
  "Add a route to the dispatcher."
  [route destruct & body]
  (let [[fn-name route destruct body] (if (symbol? route)
                                        [route destruct (first body) (rest body)]
                                        [nil route destruct body])
        fn-spec `([& args#]
                    (apply secretary.core/render-route* ~route args#))
        fn-body (if fn-name
                  (concat (list 'defn fn-name) fn-spec)
                  (cons 'fn fn-spec))]

    (when-not ((some-fn map? vector?) destruct)
      (throw (IllegalArgumentException. (str "defroute bindings must be a map or vector, given " (pr-str destruct)))))

    `(let [action# (fn [params#]
                     (cond
                      (map? params#)
                      (let [~(if (vector? destruct)
                               {:keys destruct}
                               destruct) params#]
                        [email protected])

                      (vector? params#)
                      (let [~destruct params#]
                        [email protected])))]
       (secretary.core/add-route! ~route action#)
       ~fn-body)))

pez17:02:29

Does anyone know how I could do it?

shaun-mahood18:02:26

@pez: Not sure how to do that, but it seems like it's a lot of work (especially if you are new to Clojure) - is there a specific reason you need to do that? It might be worth looking at some of the other routing libraries to see if one of them matches your needs a bit better - there's a good list under "HTTP Routing" on http://www.clojure-toolbox.com/

pez18:02:38

@shaun-mahood: thanks! Yes, I have specific reasons for this need (even if I might have tricked myself into having these reasons). That toolbox link is totally awesome. I’m still curious into how I would be able to run that macro in a loop, but I will also have a good look at silkand bidi. The latter actually seems to “think” the same way as I do.

pez18:02:11

This: Bi-directional URI dispatch. Like Compojure, but when you want to go both ways. If you are serving REST resources, you should be providing links to other resources, and without full support for forming URIs from handlers your code will become coupled with your routing. In short, hard-coded URIs will eventually break.

shaun-mahood18:02:44

@pez: Yeah, it really makes a difference (especially when starting out) to find libraries that work the same way I want them to - I spent a lot of my first time with Clojure trying to bend things in ways they weren't meant to go and it wasn't pretty.

pez18:02:33

Yes. In this case the reason I want to be able to bend secretary is that I want to use data structures for my routes. So I created a data structure and then need to wrap Secretary’s DSL in a loop… Then reading just the first paragraphs of the bidipitch: In bidi, routes are data structures, there are no macros here. Generally speaking, data structures are to be preferred over code structures. When routes are defined in a data structure there are numerous advantages - they can be read in from a configuration file, generated, computed, transformed by functions and introspected - all things which macro-based DSLs make harder.

kmandrup18:02:09

Hi guys, trying to get my head around how to use virtual-dom...

kmandrup18:02:20

Which one would you recommend? How do I make the VDom API accessible on the page? No I need to use externs or not I wonder?

venantius18:02:28

@pez if you keep going down that route I’d like to give a shameless plug for https://github.com/venantius/accountant 😛

venantius18:02:40

esp if you’re doing single-page application work

venantius18:02:58

higher level routing abstraction on top of whatever you want underneath it

venantius18:02:12

or rather, higher level navigation abstraction on top of whatever you want underneath it

shaun-mahood18:02:13

@venantius: You should get that onto clojure-toolbox

pez18:02:16

@kmandrup: Is there a reason you prefer virtual-dom over React?

venantius18:02:25

@shaun-mahood: I just submitted a PR to do that simple_smile

venantius18:02:44

I haven’t been keeping my projects up to date with the toolbox for a while so I just had to submit 4 PRs, lol

pez18:02:54

@venantius: Indeed, SPA it is. 😃 My colleague actually tried to sell Accountant on me, but I wasn’t ready. Will look into that as well. Though, I got the impression that it came with a HTML5 requirement, which I might not be ready to accept.

venantius18:02:30

it does. but these days the HTML5 expectation should already cover a pretty significant majority

exupero18:02:43

@kmandrup: cljsjs/virtual-dom is just a foreign lib for virtual-dom. vdom is more or less just some utilities for it in Clojurescript.

kmandrup18:02:50

I honestly don't understand the obsession with React... feels like overkill in some cases, when all you want is the virtual dom functionality

kmandrup18:02:43

thanks @exupero

exupero18:02:43

To my knowledge, virtual-dom doesn’t do subtree diffs like React does

kmandrup18:02:11

isn't virtual dom = subtree diff, turtles all the way down?

pez18:02:54

@kmandrup: I’m new to the whole virtual dom thing and found it via reagent and thus found React. When would you “just want” virtual dom functionality?

kmandrup18:02:09

Look at ELM, works fine just with signals and virtual dom... all the new React design patterns are inspired by the Elm architecture

pez18:02:21

@venantius: I will ponder what a HTML5 requirement would mean for our business. I think we might have a slice of the user base where IE < 10 is a bit too common.

venantius18:02:30

yeah, it’s totally a business decision

venantius18:02:15

I’d be very interested in having someone submit a PR to accountant to provide SPA event handling in a non-HTML5 environment

elsehow19:02:16

@kmandrup agreed! IIRC, cljsjs/virtual-dom is a wrapper on the matt-esch library. however, the majority of the community uses solutions that wrap react. reagent is nice, as far as those solutions go.

voxdolo19:02:13

Following up on my questions about fingerpinting static assets yesterday, I published a leiningen plugin that's aimed at playing nice with lein-cljsbuild and to a lesser extent other build systems that emit JSON manifests (we use gulp-rev too), you can check it out here: https://clojars.org/lein-buster

voxdolo19:02:44

and by published, I mean just published, as evidenced by my awesome download stats there 😄

mihaelkonjevic19:02:10

@pez keechma has a very simple router that only translates data (map -> url and url -> map) http://keechma.com/api/keechma.router.html

richiardiandrea20:02:58

Hey Bruce, let's say I am creating a library, replumb for instance, and I don't want to include in my jar the resources folder...what I do is :resource-paths [] in my project.clj root. But now figwhell does not see it anymore. An idea would be to add :resources-paths to figwheel. Summoning @bhauman 😄

richiardiandrea20:02:20

(maybe there is another more obvious solution but I can't see it now)

jrheard23:02:31

hey so what's the deal with the name figwheel

jrheard23:02:34

is that a reference to something?

jrheard23:02:39

is it just a nonsense pairing of two words?

anmonteiro23:02:53

@richiardiandrea: there's a jar-exclusions in leiningen

anmonteiro23:02:31

:jar-exclusions [#"resources"]

anmonteiro23:02:37

should do it

richiardiandrea23:02:44

yeah, did not know

richiardiandrea23:02:50

we'll see but the figwheel patch has already been submitted 😄 https://github.com/bhauman/lein-figwheel/issues/349