This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-26
Channels
- # aws (1)
- # beginners (15)
- # boot (30)
- # cider (13)
- # cljsrn (16)
- # clojure (458)
- # clojure-dev (15)
- # clojure-france (131)
- # clojure-greece (124)
- # clojure-korea (2)
- # clojure-spec (42)
- # clojure-uk (115)
- # clojure-ukraine (1)
- # clojurescript (103)
- # component (18)
- # cryogen (1)
- # datomic (4)
- # dirac (3)
- # figwheel (1)
- # funcool (13)
- # hoplon (60)
- # luminus (2)
- # off-topic (2)
- # om (28)
- # onyx (45)
- # parinfer (28)
- # pedestal (1)
- # proton (23)
- # re-frame (18)
- # reagent (36)
- # ring (1)
- # ring-swagger (5)
- # untangled (13)
- # vim (9)
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 🙂
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
(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)
hello folks - having a small issue with reduce-kv here
does not seem to like lazy sequences
(reduce-kv #(into %1 {%2 %3}) {} i-am-a-lazy-sequence)
throws No protocol method IKVReduce.-kv-reduce defined for type cljs.core/LazySeq:
any suggestions?
@michael.heuberger Right, reduce-kv
takes an associative collection, not a lazy sequence.
I think it works with a seq of entries in Clojure (not at a computer to check though)
@csm didn’t know about that, will try it. this is an electron app so I’ll see how it fits, tks
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!
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 ==
?ey thheller 🙂
@robert-stuttaford cheers 🙂
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
@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?
I’m doing a electron app with cljs and the requires are not working so I figure I go and try on a repl
@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.
in my app I tried to do that but it didnt work; I’ based on this code: https://github.com/martinklepsch/electron-and-clojurescript
I tried to hook the main.clj to require a node lib but I’m missing something in the process
its already targeting nodejs https://github.com/martinklepsch/electron-and-clojurescript/blob/master/resources/main.cljs.edn
@mping I have no experience with targeting Electron with ClojureScript. (All I can say is: what you are trying won't work in Planck.)
@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.
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
: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}}]}
@adammunoz usually i prefer to go with cljsjs
libs - is it possible in your case?
@rafaelzlisboa It's a custom library that I've written in closure
@mping: could you elaborate/repeat what you're trying to do?
@martinklepsch hi, you’re the author! cool! I’m trying to require a npm package to use it in the main process
What is the package and how are you trying to load it in your app? @mping
I think I got something working, I added it in resources/package.json and required it through js/require
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
@ska so the CSS may be in the jar and you need to include that in your page in one way or another
@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
The deps.cljs
in the JAR also only mention the JS files. But I don't know if that is relevant.
Is this ring middleware the common way of loading CSS files from CLJSJS JARs? https://github.com/Deraen/ring-cljsjs
@ska sorry for the slow response, yes Juho's middleware should help with this
also if you know the path of the file you can get/serve it via io/resource
the middleware does that in a more generic way
if you look at the implementation you can probably see whats done in ring-cljsjs
Currently looking into the newer boot-sass by Deraen and then importing the style sheet in my SCSS file.
I always forget that this wiki page exists, dang
@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?
If you already use sass then that's good approach
That's what I use myself
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?
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.
Inline is for less
Hmm.. sass has different logic. Try leaving .css out of import path.
Latest sass4clj should check for css file and inline the contents
If you have .css on import path it will write the regular css @import
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.
But there shouldn't be that line in app.css
it should be replaced by the contents of chartist.min.css
What is the line in your scss file?
Try @import "cljsjs/common/chartist.min";
Compile exception: Error: File to import not found or unreadable: chartist/common/chartist.min
had do edit again, after I checked chartist build.booit
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 ?
Works!! Thanks a lot, @juhoteperi
I'll update the wiki page with some Sass specific instructions
Yes, there is some magic here but the css import logic in sass4clj should be the same as in libsass/ruby sass
@ska https://github.com/cljsjs/packages/wiki/Non-JS-Assets#importing-using-lesssass-compiler
@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.
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?
@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
@gowder that will work but you'll have extra HTTP requests
@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.
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. 🙂
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 🙂
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
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?
@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).