This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-29
Channels
- # beginners (14)
- # boot (83)
- # cider (13)
- # cljsrn (4)
- # clojure (240)
- # clojure-argentina (1)
- # clojure-berlin (2)
- # clojure-canada (1)
- # clojure-dusseldorf (1)
- # clojure-greece (2)
- # clojure-india (2)
- # clojure-japan (2)
- # clojure-russia (23)
- # clojure-taiwan (2)
- # clojure-uk (12)
- # clojurescript (138)
- # cursive (6)
- # datomic (36)
- # hoplon (245)
- # jobs-discuss (35)
- # lein-figwheel (4)
- # melbourne (2)
- # off-topic (1)
- # om (26)
- # om-next (2)
- # onyx (23)
- # proton (8)
- # quil (1)
- # re-frame (9)
- # ring-swagger (2)
- # untangled (10)
- # yada (6)
thanks, that's helpful
you are welcome, if you figured it out, it would be cool to include it as a drop-in solution into chromex
hi guys I got an error regarding cljs.tools.reader.edn, it throw an error while reading tag inst. inst tag should be valid by default, what could be the problem here ?
(cljs.tools.reader.edn/read-string "#inst \"2010-11-12T13:14:15.666\"")
edn.cljs:383 Uncaught #error {:message "No reader function for tag inst", :data {:type :reader-exception}}
@nxqd: Seems like #inst
is just not supported by cljs.tools.reader
: https://github.com/clojure/tools.reader/blob/master/src/main/cljs/cljs/tools/reader.cljs#L818
hmm, I see we have cljs-data-readers in cljs.tagged-literals, but I wonder why this is not implemented by default in cljs reader. Now in order to use it we have to bind like this , just in case anyone has the same issue:
(defn read-cljs [s]
(binding [r/*data-readers* tags/*cljs-data-readers*]
(read-string s)))
cljs.user=> `foo
cljs.user/foo
cljs.user=> (require '[clojure.set :as set])
nil
cljs.user=> `set/foo
set/foo
[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.8.40"]
[org.clojure/tools.reader "1.0.0-alpha4"]
[figwheel-sidecar "0.5.0-SNAPSHOT" :scope "test"]
@borkdude: For a super simple project I used StupidTable the other day. Works fine. Uses jQuery...
Isn't the default opts incorrectly passed here: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L9590 ? Plus we could just omit the 1-arity version since the destructing will nil it anyways.
why do you say the options are incorrectly passed?
@anmonteiro: I think the {}
brackets should be removed or it won't be properly passed. For instance passing them like this with true
will not work.
you're right
I missed that, and now I remember that I've always used (clj->js x :keywordize-keys true)
hi guys, in clojurescript, how can I define conditional variable which is dependent from working env. The good example is that: while using devcards, I would like to have some hardcode variables for defcard
and of course I wouldn't want it to be compiled into production.
@nxqd: Personally I use :source-paths
in leiningen with different values in prod/dev. (like env/dev/clj
vs env/prod/clj
) then have the same (macro) namespace implemented differently. I have macros (onlydev ...)
and (onlyprod ...)
.
@rauh @anmonteiro there's a ticket to fix that CLJS-1540
It's a minor thing, but from time to time someone gets confused because of it (I lost more than the time to make a coffee once)
@nxqd: you should check what the behavior is for the Clojure EDN reader, @bronsa would know
@ddellacosta: just sounds like missing dependencies
@nxqd: there’s a few ways to do that. @rauh suggested one way - if you need less expressivity Google Closure defines can also work - limited to strings, booleans & numbers.
Shouldn’t :autofocus true
be a key and value you can set for an input field in sablono?
I googled for :autofocus cljs and it’s used here https://github.com/jarohen/clidget/blob/master/contacts/README.org
@urbanslug: https://html.spec.whatwg.org/multipage/infrastructure.html#boolean-attribute
urbanslug: https://github.com/r0man/sablono/issues/25 , looks like someone else uses {:auto-focus "autofocus"}
Why would they say it takes a boolean if it takes a string? Do types mean nothing to these people? (I am fairly new to writing stuff for the web)
@jaaqo: hmmm yeah it seems sabolono wants :auto-focus
the same way it takes :on-key-up
yeah I think that's cause react uses camelcase which are translated to dashed in sablono
@urbanslug: to be fair, browser are now an accumulation of 20 years of backwards compatibility
urbanslug: I'm not entirely sure if :auto-focus true even renders as autofocus attribute or just behind the scenes does focus on component-did-mount
jaaqo I’ll set it to “autofocus” then so that I don’t rely on JS for autofocus because of http://stackoverflow.com/a/4676427
@nxqd: as far as I remember, cljs.tools.reader doesn't provide inst
and uuid
readers by default to avoid circular deps between cljs and tools.reader
@dnolen it was specifically happening when I was including cljs-ajax, but went away when I tweaked the cljsbuild config. Not sure what was up but you must have been right.
Any Sente users in the house? I've set up the barebones functionality up to https://github.com/ptaoussanis/sente#now-what and, before setting up a bunch of event handlers and understanding my problem, I'm looking for the simplest REPL command to send a message from client→server (or vice versa). In the server repl, I have
(go (println (<! ch-chsk)))
And in the client repl I run
(chsk-send! [:ns/item {:hi "there"}])
, which returns :apparent-success
, but the backend repl prints nothing—perhaps because I don't see anything new in the Network tab of dev tools.
Again, I've just set up the bare minimum, up to but not including the "Now what?" section of the Sente readme, and I'm trying to send messages via a repl (before sitting down and working through the task of defining what my events ought to be).
hey guys, wondering what is the best way to iterate over a vector inside reagent component render function, using (for ...) is obvious but is there a more clojurey way?
or are you trying to avoid using namespace/function
in the namespace you are importing into?
for which you could use :refer
but I don't believe clojurescript allows for :refer :all
by design
Is there a way to use figwheel without also having figwheel serve the compiled files?
e.g. I already have a server serving my files and I only want figwheel to trigger the browser side reload
Weird question: wouldn't it be possible to implement >!!
and <!!
(as well as thread
, alts!!
, etc) in ClojureScript via child_process.fork()
and/or cluster.fork()
(when cljs is targetting node.js)?
child_process.fork()
: https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
cluster.fork()
:
https://nodejs.org/api/cluster.html#cluster_cluster_fork_env
@martinklepsch: yes, you can run your own server to serve the files and have figwheel listen on 3449 to handle the browser client websocket.
You can also just run lein ring server and lein figwheel at the same time and it should work just fine. I prefer to run both from the same repl though.
@martinklepsch: this is figwheels default behaviour.
@bhauman: @cmcfarlen thanks, I just realized this as well!
RE: my inquiry above. Here is how you might start to think about converting clojure concurrency into cljs concurrency:
(thread (println (<!! echo-chan)))
(>!! echo-chan "mustard")
; => true
; => mustard
1. Call to thread
=> Call to cluster.fork()
2. Transpile (println (<!! echo-chan))
into if(cluster.isWorker()) { <(println (<!! echo-chan))> }
3. Call to (>!! echo-chan "mustard")
=> not sure how this would be handled, or if I'm even coherent about this pseudo-code 
@george.w.singer: AFAIK, there's no <!!
or >!!
in CLJS
@anmonteiro I know. I meant to propose a possible way to implement it via nodejs clustering/forking.
howdy all
anyone here have experience debugging advanced compilation issues with cljsjs packages?
cljsjs.vega
doesn’t work under advanced compilation, but from everything I can tell the externs look fine
comparing it to react for example, which does work under advanced compilation, the externs look similar
I haven't much experience but there's a lot of ways advanced compilation can go wrong.
@sorenmacbeth: debugging advanced compilation code is not for the faint of heart
some tricks that I have used in the past: set :pretty-print true
in your project.clj
file; makes the output at least that more readable
https://github.com/oakmac/cljs-cheatsheet/blob/master/project.clj#L36 (but set it to true
when debugging)
@mvaline: What was your map vs for problem? I’ve run into a few issues where I thought map should work and some weird issues.
also sometimes I'll add things like (js/console.log "zzzzzzzz")
(or other easily searchable crazy strings) to help find where certain code paths have been "relocated"
@chrisoakman: I encountered problems with advanced compilation with a third party library called "BitPay" which lets you do public-private key cryptography with BitCoin's elliptic curve in JS
It's a node package that's glommed together into a massive CommonJS module using Browserify
https://stackoverflow.com/questions/23682924/make-browserify-work-with-google-closure-compiler
yeah could be
I think react is using it as well though?
and that works, but I’m no javascript expert, so maybe it just looks similar but react isn’t using browserify
oh well, thanks for the help
I’ll just use whitespace compilation for now
Have you tried to narrow down the section of code that is failing?
Sorry dude. I have visualization stuff I have to do in ClojureScript soon myself, I'm fearing I'll have to write it from scratch
Maybe we should talk to CLJSJS about flagging stuff that doesn't work with advanced compilation
Nah, they just run aground of google closure Gotchas and :advanced code fails tests while :simple code doesn't https://developers.google.com/closure/compiler/docs/limitations#restrictions-for-advanced_optimizations
@xcthulhu: having been around since CLJSJS started I can assure the most popular things have externs
I’m just surprised that something would be there without externs - since it’s not really useful otherwise
Oh? I don't bother with externs here and it's fine: https://github.com/Sepia-Officinalis/chromatophore/blob/master/project.clj#L79
Recommended reading - https://developers.google.com/closure/compiler/docs/api-tutorial3
In clj-bitauth I'm just calling cljsjs/bitauth, and I wrote the externs for that https://github.com/cljsjs/packages/blob/master/bitauth/resources/cljsjs/bitauth/common/bitauth.ext.js
@xcthulhu: I’m not sure about writing externs that way, I would refer to Closure docs and other extern files.
I have been thinking about doing this anyway; the latest version of Browserify doesn't make CommonJS modules by default, BitPay isn't particularly interested in my pull requests to fix this, CLJSJS isn't interested in applying a patch, so the version of BitAuth up on CLJSJS doesn't support unicode... <sigh>
@smw: it was just incorrect hiccup returned, had my map function returning a sequence of components at top level so the component was not returning a single element
Does anyone have experience working with canvas in cljs? I’m considering cljs after having built a few smallish apps (mainly consisting of simple forms) for some internal tools but now i’m scoping out options for building a web client for our platform. https://www.stringify.com/
@dfcarpenter: the http://thi.ng libraries have a bunch of canvas related things IIRC. What do you need canvas for?
Our app has a “canvas” area where we drag our entities which represent various services you can tie together (e.g drag a Nest thermostat icon/thing onto the canvas and attach it to a Lifx smart bulb/icon and then render/draw a few other things. Also each item living on the canvas should have various event handlers which can launch tooltips and modals for configuration as well as when an item is dragged onto the canvas it needs to have collison detection and a few other things
If you check out the link and scroll to the “Your connected Life - All in one place” section you’ll see what I am talking about. @martinklepsch
@dfcarpenter: SVG and react could be a solution to consider
@bhauman: I was considering that too. There are things like Fabric js, Pixi.js and such which would help (Or extending the Flipboard/canvas experiment https://github.com/Flipboard/react-canvas. I am partial to the modeling of problems in clj/cljs and though there would be more groundwork I would feel more comfortable building something in cljs.
@dfcarpenter: this is highly dependent on the problem
how do you use child selectors inside of garden?