Fork me on GitHub

hey all -- quick q if i say (let [[x val]] ...) and val is like a compile-time constant would it optimize out the construction of the obj to once (when func defined) rather than many (each time it's called)?


@nikki You can always check the JS output to see what is produced. I suspect that the GClosure Compiler would decide whether or not to make that optimization if a value were a compile-time constant. Advanced Mode compilations are pretty smart and crazy efficient.


@chrisoakman: interesting -- i was wondering if there are more optimizations available when you are equipped with clojure's semantics since you know some stuff is "immutable" or such


Hi, are there any articles about this in reagent? I am using d3 in reagent, and want to convert the Javascript to ClojureScript. How can I do this? Thanks! I am doing the cljs version of line 84 of this: .


@cmal I believe this-as is the preferred way to access JS this in CLJS:


Ah, Thank you very much @chrisoakman


We created a WeChat group for ClojureScript. if you are interested, check out in #clojure-china 🙂


@mikethompson Hi, I've read those articles and not found they talked about I've tried this, reagent/current-component, (reagent/argv this) and (this-as this ...) . None of them seems to work. I am still trying to find out how this can be done


@cmal In the article, you can see that for example :component-did-mount is associated with a function with comp as its argument. I think that might be the this you are looking for.


Or perhaps (reagent/dom-node comp)


@chrisoakman it’s a nice namespace to read through btw, goog.functions


@curlyfry yeah, those assumes that this is an reagent component or an argument passed to (fn...), but in d3 when use .on("mouseover", function(){}, this refers to an svg node which triggers an event, maybe a rect or a group or something else.


Has anyone here had a good experience with chromex (developing chrome extensions in clojurescript)? Is it possible to use the REPL/hot code reloading for testing the plugin? That would be a benefit to me over plain JS


Are there any resources for seeing how to localize a cljs app using google closure's i18n tools?


@cmal: Sorry, I'm not very familiar with d3 so I don't think I can help you further


@curlyfry ok, thanks. I think I must open a stackoverflow question for this.


@cmal the this d3 expects is a DOM/SVG node, those are naturally "hidden" by React/reagent


best way to access it is probably via a :ref


I do not know how refs are handled in reagent though


@thheller Thank you for your help.


Is there a performance difference between defrecord and deftype for function invocations?


though I didn't realize this was the clojurescript room when I answered, so I'm a bit less confident now


@martinklepsch no, defrecord is basically deftype with some added sugar


has anyone done om/reagent with web components, e.g.


I asked this question a few days ago but didn’t stick around to see if anyone answered … sorry for the repeat


@borkdude Dirac could be an example of a non-trivial chrome extension built with chromex, figwheel works[1] for me as expected, with one exception: hot reloading does not work for content scripts, but that is a chrome security limitation, not a problem of chromex or figwheel. Also chromex-sample project is already setup to work with figwheel[2]. For me the most important feature of chromex is core.async. Almost all extension apis are asynchronous, so writing plain javascript leads to the callback hell, unless you use promises or similar mechanism in modern javascript. [1] [2]


hey guys i'm currently experimenting with clojure and clojurescript, I've got a really basic server with ring jetty and compojure. Currently every endpoint serves basic html files. I'd rather have a root route "/" that serves html over http (that refers to javascript and css), and every other route actually serves text over http (data stored in edn format). The goal is to have a single page application served on the browser, where buttons and clickables invoke the server as if it were a RESTful API (since it actually is). I'd rather not have to write all the client javascript html and css manually and would much rather write it in clojure. So I'm looking over clojurescript. Can you give me some pointers on how to set up the most basic clojurescript project with lein? I don't need a lot of fancy features or third party library integration right now, I just want to get the minimal possible project up and going so I can recompile my clojurescript into javascript. I'll worry about CSS later, and at some point I will probably want to incorporate figwheel to tighten the development feedback loop. I don't want to take on too much at once though, I know what these tools do but right now I don't know much about the "nuts and bolts" of putting up the scaffolding that a clojurescript development process would require.


The example on the clojurescript website is a little too basic, it doesn't leverage lein and I have to manually invoke java. Thats alright, but I'd prefer to elevate myself just a tad. Not as far as having the whole project layout and choice of libraries done for me, but just a tad higher.


the output of lein new luminus myapp +cljs will give you a project structure I think you’re looking for


thankyou i'll look it over


before i delve deep into it, do you know whether it would be a pain to substitute my own choice of libraries?


is it an opinionated framework?


not a pain … it just helps set stuff up


here are the libraries it will "set up” (add to project.clj and create example code) for you, but you can mix or match as you see fit


it looks pretty flexible


i just don't want to end up having things happen beneath me that I won't have a chance to understand


its good to put yourself through doing things manually at least once


although i guess if thats what i want to do i should just go through the official tutorial and work with the java command


i guess my problem is lein


it feels like magic and i never understood it


@bcbradley maybe have a look at as well


don’t know if there is boot support for luminus though


I refer to luminus mainly as documentation, not working with the template myself


Hi all, any suggestions please, for how to detect a user's (imminent) BACK button navigation, in a cross-device way? e.g. for desktop browsers (no touch screen), tracking y-position to detect the (typical/common) mouse leaving the js/window would work. But not for mobile, etc. Thanks in advance for any help.


@limist back navigation is usually detected via History API


@metametadata I think he wants to "predict" if the user is going to do it.


@limist why do you want to do that though 😮


I don't think there's a cross browser way of predicting the future 🙂


@metametadata @martinklepsch Yes, trying to show users some, ahem, advice before they leave us...


@martinklepsch It's a very limited-in-time-and-space prediction, of course. 🙂


never seen anything like that 🙂 maybe you could show it in the standard dialog box on user leaving the page (using beforeunload event)


@metametadata Thought of that, but it seems there's no customizing of the message for security/privacy reasons, e.g. in Chrome


@limist cool, didn't know about that


@metametadata Yes, me neither until recently; explains why even mighty Facebook can only show you a generic alert when you close the fb tab (and when you have something written but un-posted, somewhere on page).


lol: (number? NaN) ;;=> true


@borkdude that’s to be consistent with JS typeof NaN -> “number”


That will be my koan for the rest of today.


@bcbradley If you don’t mind rather new approaches, you could also have a look at #macchiato


Pretty early stage. Very much open for input at this point. I’m sure we wouldn’t mind having an extra set of eyes, or someone asking “how am I supposed to do X?"

Aron16:12:19 is this something expected, and if it is, what am i doing wrong?


@yogthos Hey Dmitri are You available for a quick question?


has anyone else taken a look at this? It looks like a pretty good resource for beginners:


I read it about 3 years ago just before Om/Reagent, etc. became popular. Nice to see they updated it.