Fork me on GitHub
#clojurescript
<
2016-03-29
>
wilkerlucio00:03:44

thanks, that's helpful

darwin00:03:54

you are welcome, if you figured it out, it would be cool to include it as a drop-in solution into chromex

jimmy03:03:25

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}}

jimmy04:03:13

@maria: thanks for pointing out.

jimmy04:03:37

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)))

tomjack06:03:44

cljs.user=> `foo
cljs.user/foo
cljs.user=> (require '[clojure.set :as set])
nil
cljs.user=> `set/foo
set/foo

tomjack06:03:13

[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"]

borkdude08:03:00

anyone got a suggestion for a simple js library that lets me sort tables by column?

rauh09:03:22

@borkdude: For a super simple project I used StupidTable the other day. Works fine. Uses jQuery...

rauh09:03:25

If you meant CLJS: There is goog.ui.TableSorter.

rauh09:03:51

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.

anmonteiro09:03:57

why do you say the options are incorrectly passed?

rauh09:03:17

@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.

anmonteiro09:03:01

you're right

anmonteiro09:03:42

I missed that, and now I remember that I've always used (clj->js x :keywordize-keys true)

jimmy11:03:24

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.

rauh11:03:22

@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 ...).

nberger11:03:54

@rauh @anmonteiro there's a ticket to fix that CLJS-1540

nberger11:03:32

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)

dnolen12:03:50

@nxqd: you should check what the behavior is for the Clojure EDN reader, @bronsa would know

dnolen12:03:12

@ddellacosta: just sounds like missing dependencies

dnolen12:03:10

@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.

dnolen12:03:29

these can be configured via :closure-defines options, see the Compiler Options wiki

urbanslug12:03:23

Shouldn’t :autofocus true be a key and value you can set for an input field in sablono?

urbanslug12:03:32

:on-key-up works :placeholder does too but :autofocus for some reason just won't

jaaqo12:03:22

u sure it isn't :auto-focus

urbanslug12:03:49

Maybe there’s something wrong/overriding it somewhere.

dnolen12:03:21

you cannot use true or false, empty string is what you want

dnolen12:03:33

browsers are awesome!

jaaqo12:03:23

urbanslug: https://github.com/r0man/sablono/issues/25 , looks like someone else uses {:auto-focus "autofocus"}

urbanslug12:03:10

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)

jaaqo12:03:49

everything makes nothing to browsers.

urbanslug12:03:04

@jaaqo: hmmm yeah it seems sabolono wants :auto-focus the same way it takes :on-key-up

urbanslug12:03:50

@dnolen: Yeah it takes :auto-focus “autofocus”

jaaqo12:03:30

yeah I think that's cause react uses camelcase which are translated to dashed in sablono

dnolen12:03:07

@urbanslug: to be fair, browser are now an accumulation of 20 years of backwards compatibility

dnolen12:03:34

so lots of things seem arbitrary because of that

urbanslug12:03:57

:auto-focus <bool> works and seems better.

urbanslug12:03:40

Thanks to both of you btw

jaaqo12:03:19

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

jaaqo12:03:51

but as long as it works :)

urbanslug12:03:16

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

jaaqo12:03:22

rip mobile safari

bronsa12:03:09

@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

jimmy13:03:34

@dnolen: @bronsa thanks for the answer simple_smile

ddellacosta13:03:57

@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.

fasiha16:03:31

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.

fasiha16:03:59

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).

mvaline16:03:01

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?

cky16:03:42

Well, map is always great too, but for might still be more readable.

mvaline16:03:12

I'm attempting to use map though I seem to be doing something wrong

mvaline16:03:08

ohh nvm, stupid error on my part, thank you @cky

jimmy16:03:58

is there a good way to require all the thing from a ns in clojurescript ?

mvaline16:03:36

(:require [thing.namespace :as namespace])

mvaline16:03:20

or are you trying to avoid using namespace/function in the namespace you are importing into?

mvaline16:03:57

for which you could use :refer but I don't believe clojurescript allows for :refer :all by design

martinklepsch17:03:33

Is there a way to use figwheel without also having figwheel serve the compiled files?

martinklepsch17:03:10

e.g. I already have a server serving my files and I only want figwheel to trigger the browser side reload

george.w.singer17:03:09

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

cmcfarlen17:03:07

@martinklepsch: yes, you can run your own server to serve the files and have figwheel listen on 3449 to handle the browser client websocket.

cmcfarlen17:03:26

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.

bhauman18:03:06

@martinklepsch: this is figwheels default behaviour.

martinklepsch18:03:46

@bhauman: @cmcfarlen thanks, I just realized this as well! simple_smile

george.w.singer18:03:48

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 simple_smile

anmonteiro18:03:22

@george.w.singer: AFAIK, there's no <!! or >!! in CLJS

george.w.singer18:03:28

@anmonteiro I know. I meant to propose a possible way to implement it via nodejs clustering/forking.

sorenmacbeth19:03:35

anyone here have experience debugging advanced compilation issues with cljsjs packages?

sorenmacbeth19:03:27

cljsjs.vega doesn’t work under advanced compilation, but from everything I can tell the externs look fine

sorenmacbeth19:03:02

comparing it to react for example, which does work under advanced compilation, the externs look similar

xcthulhu19:03:23

I haven't much experience but there's a lot of ways advanced compilation can go wrong.

xcthulhu19:03:31

"Using string names to refer to object properties" is a common issue

chrisoakman19:03:39

@sorenmacbeth: debugging advanced compilation code is not for the faint of heart

chrisoakman19:03:29

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

smw19:03:28

@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.

chrisoakman19:03:27

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"

xcthulhu19:03:49

@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

xcthulhu19:03:38

It's a node package that's glommed together into a massive CommonJS module using Browserify

xcthulhu19:03:55

They are using Browserify too... I wonder if this is a bug in Browserify

sorenmacbeth19:03:42

I think react is using it as well though?

sorenmacbeth19:03:08

and that works, but I’m no javascript expert, so maybe it just looks similar but react isn’t using browserify

xcthulhu19:03:10

There goes the theory that it's browserify's fault

sorenmacbeth19:03:11

oh well, thanks for the help

sorenmacbeth19:03:28

I’ll just use whitespace compilation for now

chrisoakman19:03:55

Have you tried to narrow down the section of code that is failing?

xcthulhu19:03:02

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

xcthulhu19:03:25

Maybe we should talk to CLJSJS about flagging stuff that doesn't work with advanced compilation

xcthulhu19:03:33

So folks will know

dnolen19:03:31

@xcthulhu: don’t most things on CLJSJS have externs?

xcthulhu19:03:24

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

dnolen19:03:58

@xcthulhu: having been around since CLJSJS started I can assure the most popular things have externs

dnolen19:03:03

otherwise it isn’t useful

dnolen19:03:19

I’m just surprised that something would be there without externs - since it’s not really useful otherwise

xcthulhu19:03:51

I've put stuff on CLJSJS and pulled it off, but that's not the issue

xcthulhu19:03:07

If change :whitespace to :advanced here my tests fail

dnolen19:03:15

because you aren’t providing your own externs

xcthulhu19:03:27

That particular project just relies on react

xcthulhu19:03:38

And pure clojurescript

dnolen19:03:49

ClojureScript doesn’t need externs, and React already has them

xcthulhu19:03:10

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

dnolen19:03:11

@xcthulhu: I’m not sure about writing externs that way, I would refer to Closure docs and other extern files.

xcthulhu19:03:38

Gotcha. I'll go try and emulate your old React repo and try again

xcthulhu19:03:25

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>

xcthulhu19:03:48

Thanks for your pointers @dnolen

mvaline20:03:25

@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

mvaline20:03:46

just nested it within [:div (map ...)]

dfcarpenter20:03:06

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/

martinklepsch21:03:10

@dfcarpenter: the http://thi.ng libraries have a bunch of canvas related things IIRC. What do you need canvas for?

dfcarpenter21:03:30

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

dfcarpenter21:03:33

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

bhauman21:03:46

@dfcarpenter: SVG and react could be a solution to consider

dfcarpenter21:03:44

@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.

bhauman21:03:56

@dfcarpenter: this is highly dependent on the problem

bhauman21:03:09

as you know

adamkowalski22:03:09

how do you use child selectors inside of garden?