This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-23
Channels
- # bangalore-clj (1)
- # beginners (23)
- # boot (90)
- # cljs-dev (133)
- # cljsrn (5)
- # clojure (104)
- # clojure-austin (1)
- # clojure-belgium (2)
- # clojure-dev (12)
- # clojure-gamedev (4)
- # clojure-italy (2)
- # clojure-russia (6)
- # clojure-spec (30)
- # clojure-uk (117)
- # clojurescript (197)
- # core-async (25)
- # cursive (9)
- # datomic (95)
- # devops (1)
- # dirac (49)
- # emacs (1)
- # hoplon (3)
- # immutant (10)
- # lein-figwheel (2)
- # luminus (5)
- # off-topic (43)
- # pedestal (1)
- # protorepl (1)
- # re-frame (13)
- # sql (5)
- # untangled (1)
Om didn't get a feature to return multiple children from a component without wrapping them in a singular parent, right?
@the-kenny React
does not yet support it so om doesn’t as well (it will come with React v16)
Ah, I thought I remember React gaining that feature with one of the latest releases. Couldn't find it in the Changelog though
lol. Yes, NaN is actually a number... which makes sense given it is a possible result of math operations, but not when you remember what it means 😛
anyone experienced with cljsjs? I'm ablte to require the JS library I need after I put it to my dependencies. But until now every attempt to access the object in question fails... Shouldn't it be somewhere in the global space? Or do I have to add some externs manually to the project.clj?
m: Maybe give a bit more details? Which library are you talking about and what exactly have you tried to access it? Dependency vector from the project.clj and a complete (but minimal) namespace that shows what you tried (and an explanation of what you expected instead) would probably go a long way towards making people able to help
you're right.. I' about to use the Handsontable library. I added [cljsjs/handsontable "0.31.2-0"] to the depencencies of leiningens project.clj. I can require [cljsjs.handsontable] in a cljs source file without any errors and indeed the js files are included in my figwheel dev build. However, now I'd expect to access the global Handsontable object further in the code but this fails.
Hey guys, a off-topic and a little bit newbie question: There are a lot of materials and blog posts about use of Clojurescript to build SPA's but I'm a little old school guy and despite a lot of javascript in my web apps, I still do the old server side rendering through Ruby on Rails, but I want to use Clojurescript too. I found this post from @dnolen http://swannodette.github.io/2015/02/23/hello-google-closure-modules and I think that will solve the problem, so the question is: Do you think that clojurescript is also suitable to this kind of scenario?
@marciol if all you want to do is add some scripting here and there then I don’t really think you need Closure modules
advanced compiled ClojureScript w/o a bunch of 3rd party libs around the size of jQuery
which at least when I was doing RoR was perfectly acceptable to load onto any page that required JS
Unfortunately the cljsjs problem is not solved yet... Here are some more details: I' about to use the JavaScript Handsontable library via cljsjs. I added [cljsjs/handsontable "0.31.2-0"] to the depencencies of leiningens project.clj. I can require [cljsjs.handsontable] in a cljs source file without any errors and indeed the js files are included in my figwheel dev build. However, now I'd expect to access the global Handsontable object further in the code but this fails since it does not exist..
@m js/Handsontable
fails?
I included the lib in project and ns as you described and it worked:
(ns example.core
(:require [cljsjs.handsontable]))
(enable-console-print!)
(println "Handsontable" js/Handsontable)
Handsontable #object[Handsontable "function Handsontable(rootElement, userSettings) {
var instance = new Handsontable.Core(rootElement, userSettings || {});
instance.init();
return instance;
}"]
https://github.com/alexkehayias/praline - this doesn’t seem very popular - does it mean there’s an alternative everyone uses, maybe more general in some way? (e.g. no reagent dependency)
Electron knows about 'require' even in it's client-windows... I guess this might cause handsontable to not load properly. However, (js/require "handsontable") doesn't do anything here... Does anyone have an idea about this?
@m Are you trying to load it in the main process or the renderer?
Also, can talk about this more in #electron
Is anyone familiar with a recent CLJ/CLJS routing lib inspired by silk/bidi but with support for non-nested syntax? I saw it a little while back but can't remember the name of it and have had no luck googling
There was a shorthand syntax for routes involving multiple segments that didn't require nesting vectors and maps for matching
if you don’t need nesting, I’d think a hash-map would suffice to replace a router
except for the issue of wildcards I guess
I have a cljs app that breaks in advanced compilation mode, but doesn't when using the pseudo-names compiler flag. How on earth should I go about debugging this?
This is what I was after: https://github.com/funcool/bide
Definitely a candidate for the best and worst named ClojureScript library of the year
1) you’re not wrapping your script in an :output-wrapper
causing a collision with something else on the page
2) you’re relying on cljs->js
to convert some JS value which will clash with Closure generated properties
@dnolen Awesome. I'll investigate and report back. It's a conundrum, but a delightful one.
for the record I believe cljs->js
has too many accumulated issues and in general I would avoid it. I’ve built a lot of apps and I can’t remember a single time where I thought I needed it
I've taken note. My application doesn't use cljs->js
directly, but one if its dependencies might. I don't know yet.
so is this cljs->js
you guys are talking about something different from clj->js
? is it an inferior alternative for using the #js
reader macro?
it’s definitely one of these we probably shouldn’t have added - even though people keep asking for it
so if I’m using js that expects a js object or array should I be using #js for constructing it or some smart alternative that’s escaping me or?
dnolen: asking as a relatively naive cljs user, is there a blogpost or other that surveys that options, pros & cons, etc.
I'm trying to stick a Babylon component into an existing reframe app that's built with boot. I've never used any of those technologies before. It's possible I've bitten off too much at once. Anyway, what's the best way get a different version of Babylon than is currently provided with cljsjs/babylon?
@danielsz I would try to compile in advanced mode with source-maps, Chrome DevTools could give you more context with reformatting and source mapping
once I had similar issue caused by names aliasing in advanced mode, with pseudo-names the problem went away because the naming scheme prevented the clash
@pandeiro: I also like sibiro for routing, it's simple and you can use it on the back-end too if you need to: https://github.com/aroemers/sibiro
yep, which cljsjs provides, but it's an older version and is breaking in a way that makes me wonder if it ever worked.
@chouser it’s just ClojureScript compiler option, so hopefully nothing to learn wrt. boot other than how to pass it along
well I'm apparently using boot to serve the files to the browser, and so I need to get it to serve the babylon files too. My first attempt to do that failed, but I can pursue it more.
ClojureScript copies everything to :output-dir
and whatever you’re using should be serving from there or allow you to configure that
@chouser https://clojurescript.org/reference/dependencies has a Foreign deps section
I barely know what I'm talking about. I typed "boot dev" and then can point my browser at localhost:3000. I can browse to static resources that are in resources/public/, but when I added a symlink there to the babylon.js directory, I was getting 404s for files there.
I'll keep trying. I just thought cljsjs might be easy and convenient, but it hasn't panned out yet.
@chouser speaking about cljsjs, I don’t rely on internets to make externs for me, I tend to write a thin wrapper cljs library for js library using string names and include the js lib in html file directly outside my :advanced mode compilation. This way I completely avoid dealing with externs, :foreign-libs and related stuff: https://github.com/binaryage/cljs-oops#side-stepping-the-whole-externs-mess
Thank you, @darwin. My first instinct was to launch a dirac repl, actually. (and then I saw the message about advanced mode).
darwin: "You required cljs-devtools library in a project which is currently compiled with :optimizations :advanced."
OK, great. It suggests to use the preloads compiler option, which I wasn't sure about.
you should be able to use source-maps and minified js reformatting in normal Chrome DevTools
@chouser are you using tenzing by any chance?
@chouser if things are set up correctly adding a cljsjs package is 1) adding the dep 2) requiring it 3) using it
@mobileink no but that sounds like great contribution to the ClojureScript site https://clojurescript.org/guides/quick-start
@martinklepsch I don't know what tenzing is. I added and required the cljsjs/babylon dep. When I attempt to use it, it breaks somewhere inside the Babylon code, so it's loading, but who knows what it's doing. I'll attempt more direct control of the babylon code loading.
I’ll say again that updating the ClojureScript site docs is like the lowest of lowest hanging fruits if you want to have a big impact 🙂
@chouser is your code up somewhere?
@chouser happy to take a look if so
people often say they don’t feel like they have the knowledge to write up a guide - but that is unfounded - someone who knows is going to review the PR!
@martinklepsch Wow, that's generous. Give me a few more hours to poke at it. This will definitely all go up online at some point, working or no.
@dnolen i'm game, i need to figger this stuff out any way. anybody else got any recommendations? fwiw i have data structures i need to pass to js objs. i use clj->js, out of pure ignorance (path of least resistance). i reckon good docs would start with use cases, then pros and cons of various techniques?
@mobileink guide should start with fundamentals
clj->js
should be called out as convenience but the dangers for advanced compilation should be noted
it doesn’t need to be a particular long or verbose guide - and we can now direct people to it that have questions
I personally have always referred to this guide for that kind of stuff. http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/
me too, great resource. but i think it needs some more details, and for the official docs it needs to be a bit more concise (imho).
the obvious question: if clj->js is "not so great", but #js
is not recursive, what to use if you have e.g. a nested structure of maps, sets, vectors, etc.?
and another naive question: how often does it happen that interop is not needed in real-world situations?
but it seems unlikely in any real application that talks to some non-Clojure(Script) thign
ok, i'm a bit confused about #js
. if i recieve a hairy clj structure from the server (e.g. using transit), then to translate it to js w/o clj->js, i need to walk it somehow to insert #js
? that sounds like a dumb q to me, have mercy. 😉
fyi if i set a property to a hairy js structure, polymer bindings will propogate the contained data automagically, with no coding.
@mobileink I've experienced that, absolutely. When producing or consuming a non- trivial clj nested structure, clj->js
is handy. I have no good answer.
@mobileink server/client comm concerns really are out of scope for what this guide is about
but stepping back a bit, if my integration is just to feed stuff into Polymer, I don’t know what value there is marshaling immutable Transit
but: would walking be (sometimes?) more efficient than clj->js? that would be surprising to me, at least.
re: feeding stuff to polymer: i might be doing it wrong, but i transit some data to my frontend, then shove it into datascript, so i can muck with it at will in cljs. then i grab some of it and pass it to polymer.
dnolen: yikes
so i might pass some data to one component, and some other data to another component. make sense?
@mobileink sure if the amount of data your pushing throw is small that’s ok, I’m just saying if you think about it up front you can avoid lots of problems
e.g. just send json in the first place? i agree avoid marshalling, but there's an unavoidable tension if i want to do data manip in cljs while still talking to js objs, no? i obviously need to spend more time actually doing this, heh.
@dnolen All this talk about clj->js
and in the end it was the :output-wrapper
thingy. I was pulling my hair out. Turns out I'm not the first. https://dev.clojure.org/jira/browse/CLJS-1520
clj->js
collisions are less likely - I think most people just monkey-patch it if they hit a problem
if i can come up with a sane and concise discussion of this stuff i'll sub a doc pr.
@dnolen I see. Maybe auxiliary tooling is in a good position to be doing something. boot-cljs
has a related ticket. https://github.com/boot-clj/boot-cljs/issues/64
@danielsz my vote would be to deprecate it and perhaps make a new thing that just uses walk and has no bells or whistles and no extension points
@dnolen Yes indeed, if you could do it again, you would enforce :output-wrapper true
as a default, no?
Certainly for advanced compilation where collisions are likely to happen without it.
There seems to be some confusion regarding where the best place to enforce this option should be. https://github.com/boot-clj/boot-cljs/issues/64#issuecomment-166929728
Howdy. Newbie question coming up...
I've imported goog.events.EventType. What is the difference between EventType/KEYDOWN and EventType.KEYDOWN.
@dnolen There seems to be some resistance to change the defaults in build tools just to stay aligned with the compiler defaults. What's your take on that? Is there any reason not to enforce output-wrapper true
for advanced compilation in our build tools?
Both seem to work. Using slash is what I'm used to from Clojure. But it gives an undeclared Var error. Using dot works a-ok. But seems wrong.
and whatever problem you hit with the default somebody will hit another problem with the new default
that said, I don’t have any real issues if downstream tools want to do more or different stuff
@dnolen Right. It's a tricky one. lein-cljsbuild
enforces output-wrapper
for advanced builds, and at boot-cljs
we are considering it too. I am in favor because this is such an obscure source for bugs.
oh! hah -- apparently I'm using bootstrapped cljs. I guess boot is just for serving files and triggering reloads in this model?
hey guys, what's the correct way of converting string to number in cljs? why this (int "1")
works but this (int "11111111111")
returns negative num?
js/parseInt
is the right thing to use
WAT?
cljs.user> (js/parseInt "--000--")
NaN
cljs.user> (number? (js/parseInt "--000--"))
true
maybe you need more pre-processing before making these things numbers?
it doesn’t take “not” as literally as we would like
clj on the jvm does the same thing
it’s a static field in java.lang.Double Double/NaN
it’s part of the floating point spec to have that value
or value(s) even iirc
https://en.wikipedia.org/wiki/NaN - quiet nan, signaling nan, plus some bits for a “payload” that usually goes unused
Is there a good tutorial for getting figwheel running with a non-Ring server (in my case django)
emccue: if I understand correctly, no tutorial is needed, you cljs code will send network calls against your Django server (localhost in dev?)
That works fine usually, but the way it is set up, I need to test data preloaded by the server which is just put in the head
emccue: that data lives in the server and unless you expose it using a GET or something you won't be able to access it (it is python right?)
Oh ok, so everything in the browser should be visible, you just need to use some cljs interop. I don't think figwheel handle this specifically but I might be wrong. You can ask in #lein-figwheel as well.