Fork me on GitHub
#clojurescript
<
2016-10-26
>
jrheard00:10:52

klipse really is something special - it’s fun to play around with these examples and eg set the fizzbuzz one to go to 20 instead of 10, etc 🙂

jrheard00:10:50

i’ve been continuing to use http://app.klipse.tech/ a lot for perf investigations, will eventually write a blogpost 🙂 gained a 20% perf improvement in my app today by optimizing a particular function [called in a tight loop] using klipse interactively + http://blog.fikesfarm.com/posts/2015-12-04-boolean-type-hints-in-clojurescript.html

jrheard00:10:12

(there’s probably a more elegant solution that still causes the same perf benefit, but https://github.com/jrheard/voke/commit/654427e98aa3d231312581c8b20d7128dbbb4aa8#diff-0b39f35abfcfaaa9253f5be754172c44 is the diff fwiw)

michael.heuberger00:10:00

hello folks - having a small issue with reduce-kv here

michael.heuberger00:10:17

does not seem to like lazy sequences

michael.heuberger00:10:55

(reduce-kv #(into %1 {%2 %3}) {} i-am-a-lazy-sequence) throws No protocol method IKVReduce.-kv-reduce defined for type cljs.core/LazySeq:

mfikes02:10:02

@michael.heuberger Right, reduce-kv takes an associative collection, not a lazy sequence.

Alex Miller (Clojure team)02:10:36

I think it works with a seq of entries in Clojure (not at a computer to check though)

mping08:10:16

@csm didn’t know about that, will try it. this is an electron app so I’ll see how it fits, tks

bago09:10:18

Hello guys, i’m trying to port a simple lib from Clojure to ClojureScript and I’m stuck with this question: how do i replace float?? thanks!

bago09:10:52

ok, i did my homework and here is my solution, in javascript:

function isFloat(n){
    return Number(n) === n && n % 1 !== 0;
}
that i translated to:
(defn float? [n]
  (and (== (js/Number n) n)
       (not (== (mod n 1) 0))))
do you think this can work? should i use identical? instead of ==?

thheller09:10:56

strictly speaking all numbers in js are floats

mping10:10:27

Hi guys, I’m giving a shot in cljs, and I thought I could do this from anywhere: (require '[cljs.nodejs :as node]) but it didnt work. I’m using planck as a repl

mping10:10:45

I thought cljs.nodejs could be required

mfikes12:10:27

@mping The inability to require cljs.nodejs in Planck is because Planck is based on JavaScriptCore, not Node. (If you were to try to evaluate (js* "require”), which that namespace does, the evaluation will fail because JavaScriptCore does not define this function; it is specific to Node.) What are you trying to do?

mping12:10:58

@mfikes I’m trying to load a node lib

mping12:10:34

I’m doing a electron app with cljs and the requires are not working so I figure I go and try on a repl

mfikes12:10:48

@mping You mean a lib from NPM?

mping12:10:23

I’m guessing I’m missing some understanding of how this works

mfikes12:10:40

@mping ClojureScript doesn’t directly support NPM dependencies. It does support CommonJS FWIW: it does this via Google Closure. Planck doesn’t use Google Closure. But you could try to treat the lib as a foreign lib and simply use Node’s require, as you are doing (I don’t have any experience with that). But, to do that, you need to be in a Node JavaScript environment.

mping12:10:40

in my app I tried to do that but it didnt work; I’ based on this code: https://github.com/martinklepsch/electron-and-clojurescript

mping12:10:27

I tried to hook the main.clj to require a node lib but I’m missing something in the process

mping12:10:51

but I’m quite new to this

mfikes12:10:00

@mping I have no experience with targeting Electron with ClojureScript. (All I can say is: what you are trying won't work in Planck.)

mping12:10:13

thanks, at least I wont try it anymore 😄

rohit12:10:30

@mping: have a look at https://github.com/ducky427/electron-template. This is my (slightly outdated) template for creating a electron project which uses ClojureScript.

Adam Munoz12:10:49

Hello I have a js file (library.js) compatible with closure. I'm using figwheel which uses cljsbuild and in project.clj I have included the :libs option with the path to my library.js However it is completely being ignored when I build or launch the repl. Even if I intentionally write a wrong path to library.js I don't get any errors. So I'm suspecting that I'm not putting the :libs file in the right place

Adam Munoz12:10:54

:cljsbuild {:builds

              [{:id "dev"
                :source-paths ["src"]

                :figwheel {:on-jsload "sdk-2.core/on-js-reload"
                           :open-urls [""]}

                :compiler {:main sdk-2.core
                           :asset-path "js/compiled/out"
                           :libs ["path/to/library.js"]
                           :output-to "resources/public/js/compiled/sdk_2.js"
                           :output-dir "resources/public/js/compiled/out"}}

               {:id "min"
                :source-paths ["src"]
                :compiler {:output-to "resources/public/js/compiled/sdk_2.js"
                           :main sdk-2.core
                           :libs ["path/to/library.js"]
                           :pretty-print false}}]}

mping12:10:58

@rohit thanks I’ll have a look

rafaelzlisboa12:10:13

@adammunoz usually i prefer to go with cljsjs libs - is it possible in your case?

Adam Munoz12:10:49

@rafaelzlisboa It's a custom library that I've written in closure

martinklepsch13:10:20

@mping: could you elaborate/repeat what you're trying to do?

mping13:10:04

@martinklepsch hi, you’re the author! cool! I’m trying to require a npm package to use it in the main process

martinklepsch13:10:38

What is the package and how are you trying to load it in your app? @mping

mping13:10:19

I think I got something working, I added it in resources/package.json and required it through js/require

ska13:10:55

Hi. Has anyone successfully used chartist? I included the CLJSJS package, I can load chartist no problem. The graphs look ugly and I thought it may be the CSS. But now I find no way to load the chartist CSS at all. /me feels stupid

martinklepsch13:10:18

@ska so the CSS may be in the jar and you need to include that in your page in one way or another

ska13:10:48

@martinklepsch Yeah, the CSS in the JAR. It is the "one way or another" part that I don't grok. Also, while boot extracts the minified JS from the JAR it does not seem to do that for the CSS. At least, I can not find the CSS underneath ~/.boot

ska13:10:53

The deps.cljs in the JAR also only mention the JS files. But I don't know if that is relevant.

ska14:10:08

Manually downloading the CSS and adding to my app fixes the ugly graph.

ska14:10:09

Is this ring middleware the common way of loading CSS files from CLJSJS JARs? https://github.com/Deraen/ring-cljsjs

martinklepsch14:10:53

@ska sorry for the slow response, yes Juho's middleware should help with this

martinklepsch14:10:13

also if you know the path of the file you can get/serve it via io/resource

martinklepsch14:10:28

the middleware does that in a more generic way

martinklepsch14:10:13

if you look at the implementation you can probably see whats done in ring-cljsjs

ska14:10:24

Currently looking into the newer boot-sass by Deraen and then importing the style sheet in my SCSS file.

ska14:10:50

Oh, and no worries about slow responses. Thanks for any responses in the first place. 🙂

martinklepsch14:10:42

I always forget that this wiki page exists, dang

ska14:10:11

@juhoteperi, thanks. That's where I found the link to the less4clj and sass4clj hint. Would you be able to suggest one of the approaches to me?

juhoteperi14:10:45

If you already use sass then that's good approach

juhoteperi14:10:14

That's what I use myself

ska14:10:26

OK, will try then. Am currently still on boot-sass-0.2.1. Will changing that to 0.3.0 give me the latest version from your new project?

ska14:10:48

Thanks. Will come back with results...

ska14:10:23

Hm, I could silence the compiler by removing the (inline) part from the example on the wiki page. That was for less anyway. But my webapp still does not find the CSS file.

juhoteperi14:10:38

Inline is for less

juhoteperi14:10:17

Hmm.. sass has different logic. Try leaving .css out of import path.

juhoteperi14:10:03

Latest sass4clj should check for css file and inline the contents

juhoteperi14:10:31

If you have .css on import path it will write the regular css @import

ska14:10:35

Maybe I'll have to add a route to my ring app?

ska14:10:26

So, my app.css now has a new line at the beginning: @import url(chartist/common/chartist.min.css); But my ring app does not serve anything under that path.

juhoteperi14:10:54

But there shouldn't be that line in app.css

juhoteperi14:10:04

it should be replaced by the contents of chartist.min.css

juhoteperi14:10:15

What is the line in your scss file?

ska14:10:44

@import "chartist/common/chartist.min.css"; is my first line in my app.scss

juhoteperi14:10:55

Try @import "cljsjs/common/chartist.min";

ska14:10:26

Compile exception: Error: File to import not found or unreadable: chartist/common/chartist.min

ska14:10:33

Hang on, will try your edit

juhoteperi14:10:56

had do edit again, after I checked chartist build.booit

octahedrion14:10:59

hi, I'm trying to use modular compilation, and although non of my modules have a dependency on react, nevertheless cljs_base.js includes react -- can I make it only include cljs without removing react etc from my project.clj deps vector ?

ska14:10:05

File to import not found or unreadable: cljsjs/chartist/common/chartist.min

ska14:10:35

Oh, next edit compiles

ska14:10:04

Works!! Thanks a lot, @juhoteperi

juhoteperi14:10:29

I'll update the wiki page with some Sass specific instructions

ska14:10:44

Too much magic going on underneath. I think, I am getting too old for this. 😉

juhoteperi14:10:45

Yes, there is some magic here but the css import logic in sass4clj should be the same as in libsass/ruby sass

ska14:10:45

@juhoteperi That looks better. I think, adding a hint how to get at the correct path (look into JAR, find asset, copy path, add package, whatever) would have been very helpful for me.

gowder14:10:10

FWIW @ska it seems to work the easy way for me with just including the CDN versions of the chartist JS and CSS, in the html, in dev. Which obviously won't work for advanced compilation, but maybe the lazy easy solution is just to do that and then slap the externs from cljsjs in before compiling or something?

juhoteperi14:10:55

@gowder @ska It is also possible to just use JS from Cljsjs and then CSS from CDN, then you don't need to use sass/less compiler to embed css or middleware the serve them

martinklepsch14:10:56

@gowder that will work but you'll have extra HTTP requests

ska14:10:06

@gowder, thanks for your hint. I do not think, I can go for any CDN package, as I have to ship a fully self-contained JAR. And I always like to keep dev and prod environments as similar as possible.

gowder14:10:40

sensible enough 🙂

ska15:10:50

Once I found out that the missing CSS file was actually my problem (by adding it manually and seeing that it works), it was easy to find the wikipage. The page is a bit intimidating to a newcomer. Thus, when @dearen said, that going for the SASS way would be good, I had my decision on that. The next problem was that I pasted the less example to my sass and expected it to work. Stupid, I know; this has been improved by the latest edit. The only remaining problem would have been to find the correct filename. There is now a paragraph in the wiki page, too. So, I guess the next newcomer to this problem will have a good chance of finding the pieces. 🙂

juhoteperi15:10:43

The Sass way was not documented yet as I just released sass4clj version which supports this like a week ago, so you happened to be the first one to try this 🙂

ska15:10:25

What I am trying to say is: 'good job, thanks' 🙂

arohner21:10:27

Has anyone used https://github.com/cljsjs/packages/tree/master/react-mdl? I’m getting Cannot read property 'childNodes' of null when using the patched MDL.js

noprompt22:10:55

is it possible to configure the reader use by the clojurescript compiler?

noprompt22:10:03

in say project.clj

noprompt22:10:24

i don’t see an option but i may have overlooked something.

denik22:10:41

What’s react.js actually doing in all the CLJS wrappers? It seems like we don’t use its diffing capabilties but instead cljs equality semantics. React’s lifecycle hooks seem simple enough to implement. Additionally there are plenty of issues talking to react, e.g. making proper react elements on the server side and pushing around props in js objects. Am I overlooking something?

shaun-mahood22:10:39

@denik: Part of the reasoning I've heard in previous discussions has been so that it enables us to take advantage of the wider react ecosystem and performance improvements made on react. It's a similar reasoning as for the rest of the interop/hosting story, I think. It's definitely not the only approach though, I believe Hoplon has it's own vdom implementation (though you might want to check that).

jrheard23:10:00

just curious: is core.logic boostrap-cljs compatible? (i have a fuzzy understanding of what that means and how a library achieves compatibility, am doing some reading to try to solve that)