This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-14
Channels
- # beginners (74)
- # boot (23)
- # braid-chat (7)
- # cider (5)
- # clara (3)
- # cljsjs (17)
- # cljsrn (1)
- # clojure (105)
- # clojure-austin (9)
- # clojure-new-zealand (34)
- # clojure-poland (2)
- # clojure-russia (177)
- # clojure-uk (41)
- # clojure-ukraine (2)
- # clojurescript (130)
- # component (1)
- # core-async (2)
- # core-matrix (6)
- # cursive (7)
- # data-science (103)
- # datomic (24)
- # emacs (15)
- # funcool (4)
- # hoplon (21)
- # immutant (151)
- # ldnclj (76)
- # melbourne (1)
- # off-topic (8)
- # om (152)
- # om-next (1)
- # onyx (26)
- # parinfer (38)
- # re-frame (13)
- # reagent (14)
- # spacemacs (1)
- # vim (92)
- # yada (1)
I was just beginning to work through the Om tutorials, now I’m thinking I’ll have to look at Re-frame instead
I recently used re-frame to implement a Minesweeper game. That’s my new frontend code kata. 😉
At work we have this sort of memory matching game we give to each prospective front-end developer as a test project. That’s my go to when I’m learning something new. I figure I should be able to come up with a convincing implementation if I’m asking anyone else to
@bwstearns I played that game a couple of years ago. It's quite fun!
Hey, anyone knows if there is some sort of track kept of all the CLJS videos in conferences ?
ah ok thanks, and one more question, any suggestions for making responsive layouts in CLJS based project ? does one just use SASS/LESS and related stuff, or there are some fancy CLJS style of things for that ?
there's https://github.com/noprompt/garden though, I just use less, and figwheel's css loading for development. whatever you choose for css is rather orthogonal to chosing to use cljs
@zilvinasu: I use garden (with https://github.com/martinklepsch/boot-garden) which has a very nice benefit of having access to all the normal Clojure abstractions when composing stylesheets
@zilvinasu: I find http://basscss.com to have some overlap with functional programming thinking and really enjoy using it
akjetma: Instead of ;
why so? Just read that comment macro causes a form to return nil
"The form following #_ is completely skipped by the reader. (This is a more complete removal than the comment macro which yields nil)."
one thing about the comment macro is that the body is still read (so it has to be syntactically valid)
What is reading comments good for? Better developer tools? I would’ve expected the two to be semantically equal.
Well yeah I guess it could be used by certain DSLs but that’s unexpected which doesn’t necessarily mean bad.
it's much easier to comment out a form with #_
than ;
. You'd need editor support to move trailing parens to a newline otherwise in some cases
> one thing about the comment macro is that the body is still read (so it has to be syntactically valid)
I think this is equally true for #_
@urbanslug: #_
is useful since it will also work properly with multi-line forms where ;
would not. Also, you can have multiple #_#_
and ignore two form. #_
can also stand alone on the line preceding the form to ignore (and then you can comment the #_
with a ;
to disable it. Possibly cursive specific: I have my code littered with #_
since I can eval the form with a keypress (not possible with ;
), you also still get proper paredit functionality within a #_
commented form.
martinklepsch: I don’t think so "The form following #_ is completely skipped by the reader. (This is a more complete removal than the comment macro which yields nil).” from http://clojure.org/reference/reader
Well it still has to see that it is a form so at least the parenthesis have to match I guess.
> The form following #_ is completely skipped by the reader. For that to be possible it has to correctly identify the form as @nha noted
the problem is that i want to include or not some namespaces depending on compile-time known environment variables
I like reagent, but om next is looking pretty snazzy. ratoms + hiccup syntax by default are pretty cool
help me with Html5History
clojure
(def history
(doto (Html5History.)
(.setEnabled true)
(.setPathPrefix "")
(.setUseFragment true)))
Hi everyone! I'm have a problem that I hope someone here can help me with. I'm building a Clojurescript + Reagent frontend and I want it be split into 2 different (frontend) apps, served from within 2 different HTML pages: the main app, and a login page. Both should be built using Clojurescript, and ideally I want the source code to be in the same project, and both should be handled by the same lein-figwheel. Is this possible?
I'm not trying anything yet, because I have no idea how to go about it. But I have heard of Google Closure modules support
yes 2 builds works for dev and if you want you can then have a deployment builds that splits things into modules
so I could have a production build that uses Google Closure modules to so I can split out the common code. And for dev I would have 2 builds, one for each page?
Let's say that for the moment I want to keep using Figwheel (I'm new to most of this, and I've just learnt this tool chain), would I be able to run the 2 dev Figwheel builds simultaneously?
@daan: Something else to consider, ClojureScript works well when you are producing a single output JS file. Google Closure Advanced mode optimizations can do amazing things to reduce your overall codebase.
My default approach is to go for producing a single file until it gets too big that I feel like it needs to be split.
Hi guys, this is my first time here, so please don’t be too harsh on me I have a question regarding the outfile, which is the result of compiling clojurescript targeting
:nodejs
. The resulting file looks like this:
#!/usr/bin/env node
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
Math.imul = function (a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
}
}
var path = require("path");
try {
require("source-map-support").install();
} catch(err) {
}
require(path.join(“.”,”target”,goog","bootstrap","nodejs.js"));
require(path.join(“.”,”target”,"cljs_deps.js"));
goog.global.CLOSURE_UNCOMPILED_DEFINES = {"cljs.core._STAR_target_STAR_":"nodejs"};
goog.require("server.core");
goog.require("cljs.nodejscli");
I am concerned with the calls to require
:
require(path.join(“.”,”target”,"goog","bootstrap","nodejs.js"));
require(path.join(“.”,”target”,"cljs_deps.js"));
Long story short, this code depends on the CWD, therefore this node program can only be run from leiningen project root. Is this on purpose? Changing to:
require(path.join(__dirname,"goog","bootstrap","nodejs.js"));
require(path.join(__dirname,"cljs_deps.js"));
would make it runnable independently of the process cwd.You might want to try that first - which would simplify your build setup - and then have something like initLoginPage()
and initOtherPage()
functions to act as entrypoints on your different pages.
I get your point, but in this case it's not about size or code-management, it's more that I feel the login code should be on a completely different page, apart from the SPA main page
Right; there are many ways to skin this cat 😉 Just thought I would add that idea.
@karolmajta: there is an open ticket for that somewhere I think .. not sure if there is a patch
ok, i’ll search for it
@theller it seems there is no clear conclusion on this one, do you guys have any thoughts? I’ve commented, that current behaviour makes clojurescript hard to use for commandline and desktop applications (for servers, the CWD can be usually set to match the expectation). Do you guys have any thoughts on this? We’re currently doing electron application and this is a real pain when packaging the app.
@karolmajta: I think you could just use your own modified copy of that file, I guess it won’t be changing much, or wrap it with your own helper script which will change current directory to the one expected by that file
Changing a CWD of a process is just bad (but this is what i do now), what if i wanted to write a script for listing current directory? Surely not a good long time solution.
Using custom shim file surely might be better. One thing i don’t like is the fact that if i change the :output-to
i would have to modify the shim too, but i think i could live with that.
@karolmajta: I don't use node but I agree that the bootstrap should just use __dirname
. I see no reason why it shouldn't.
In the jira issues there are some concerns about breakage, but to be honest, I don’t fully understand them.
Does anybody know if there is a hidden gem somewhere that allows you to print a js regex object to include modifier flags. Ex:
(print (re-pattern "(?i)RUN")) => #"RUN"
I'd love to get the original string back somehow (I could always use .toString
and reconstruct manually but was hoping for some symmetry in the core api 
What would be the structure/function to make this go-loop
run in parallel with core.async
? :
https://gist.github.com/nha/2003f3a5b738e72cb75e
nha: how would you propose making parallelism ever happen in js?
@nha: I guess you want to use alts!
: https://clojuredocs.org/clojure.core.async/alts!
and, by the way, that channel wrapping in sample-async-fn is not needed - go returns a channel, which will receive the result value of the go body expression and then closes: `(go (<! (timeout t) s)` should be equivalent (except for closing)
Anyone know a good method for pretty printing edn so that it can be rendered on the page? I was looking at cljs.pprint/pprint, but it seems to only want to output to the js console.
The performance of syntax-quote seems to degrade on nested structures in Safari. For example, the following expression will hang on Safari 9.0.3 (OS X 10.11.3) using clojurescript 1.7.228: `[({:person [:db/id :name {:address [:street]}]} {:id '?id})] whereas the following works: [(list {:person [:db/id :name {:address [:street]}]} {:id '?id})] Firefox and Chrome does not have this issue. Is anyone else experiencing this on Safari?
@symfrog: I think it's a known issue in safari, and there's a ticket in jira about it, and the workaround involves using :static-fns true
for cljsbuild... but I can't find the ticket right now
@nberger: Thanks, I searched jira earlier for a possible known issue, but did not find one, will keep on searching now that I know that one exists.
no worries. this might be the issue: http://dev.clojure.org/jira/browse/CLJS-910
@symfrog: I ran into that performance issue with safari. I just went with using the list form. Actually eliminates a source of bugs with ` vs ' and missing ~
@kspear: devcards has a nice utility for edn->html: https://github.com/bhauman/devcards/blob/master/src/devcards/util/edn_renderer.cljs
@nberger: thanks, passing :static-fns true to the compiler opts solved the issue, out of interest the jira issue suggested this occurs only with :optimizations :whitespace, but I was also experiencing it with :simple
I think you'll see the slowdown with everything but :advanced, but I haven't explored that yet at all
@cmcfarlen: thanks, in the end I will probably use the list form instead as you suggested, what are the downsides with using :static-fns true and function eval in the repl?
@symfrog: I think it would eventually bite me (or a coworker) when I least expect it so I decided to not set it
@bwstearns: Like google maps type mapping?
@shaun-mahood: like the geographic kind not the conceptual or data-correspondance kind
@bwstearns: I've not looked into anything clojurescript specific, but if you can't find anything openlayers is written with the Closure compiler so I assume it might play nice with cljs http://openlayers.org/en/v3.7.0/doc/tutorials/closure.html
Here is a sample clojurescript repl.clj
config file:
(require '[cljs.repl])
(require '[cljs.repl.node])
(cljs.repl/repl
(cljs.repl.node/repl-env)
:watch "src"
:output-dir "out-repl"
:repl-requires '[[cljs.nodejs :as node]
[cljs.core.async :refer [put! chan <! >!]]])
Notice the part that :repl-requires
some useful cljs.core.async
functions.
Question: How does one :repl-require
macros? In particular, how would one :repl-requires
the go
macro from cljs.core.async.macros
(i.e., so that when one loads up a nodejs repl, the go
macro is immediately usable)?