Fork me on GitHub
#clojurescript
<
2017-01-16
>
bones03:01:26

I’ve seen David Nolan’s webinar on using core.async for UI, anyone know of any further material specifically for architecting UI components with core.async?

mruzekw03:01:04

Tonsky implements a flux-like architecture with core.aysnc here: https://github.com/tonsky/datascript-chat

mruzekw03:01:49

If you look at the code, he uses core.async for a “command channel”…I’m guessing similar to an actions channel

dottedmag11:01:33

Is there a documentation for cljs reader? Either a reference or a diff from Clojure.

dottedmag11:01:46

I can't find any mention of #js in docs.

dottedmag11:01:36

Also is there a predicate to distinguish between cljs maps and JS objects?

dottedmag11:01:02

Hmm, found #js here, but it's quite obscure: http://cljs.github.io/api/syntax/dispatch

darwin11:01:39

(tagged literals are pluggable)

dottedmag12:01:49

@darwin Thanks. I have already found it, so it was mostly a grumbling about the docs status. Built-in tagged literals ought to be prominently specified in docs. I suppose I should go and add it there.

dottedmag12:01:36

Also, I'm having a hard time getting cljs.spec to work:

cljs.user=> (require '[cljs.spec :as s])
nil
cljs.user=> (s/conform object? {})
#object[Error Error: No protocol method Spec.conform* defined for type function: function cljs$core$object_QMARK_(x){
if(!((x == null))){
return (x.constructor === Object);
} else {
return false;
}
}]
	 cljs$core$missing_protocol (jar:file:/Users/dottedmag/.m2/repository/org/clojure/clojurescript/1.9.293/clojurescript-1.9.293.jar!/cljs/core.cljs:282:7)
cljs.user=> (s/conform even? 1)
#object[Error Error: No protocol method Spec.conform* defined for type function: function cljs$core$even_QMARK_(n){
if(cljs.core.integer_QMARK_(n)){
return ((n & (1)) === (0));
} else {
throw (new Error([cljs.core.str("Argument must be an integer: "),cljs.core.str(n)].join('')));
}
}]
	 cljs$core$missing_protocol (jar:file:/Users/dottedmag/.m2/repository/org/clojure/clojurescript/1.9.293/clojurescript-1.9.293.jar!/cljs/core.cljs:282:7)

dottedmag12:01:47

I have tried to create a spec via (s/def ::even? (s/and number? even?)), but passing it to s/conform gives me No protocol method Spec.conform* defined for type cljs.core/Keyword: :cljs.user/even?. Looks like something is broken at my side, as it's a copy-paste from cljs test suite.

dottedmag12:01:31

But I have no idea where to start to begin debugging it.

darwin12:01:45

hmm, strange, spec has worked for me just fine under cljs

darwin12:01:05

@dottedmag I have just tested it in my cljs repl and the code works for me, I’m not seeing the error you are getting

darwin12:01:20

but I’m running on top Clojure 1.9 alpha 14

dottedmag12:01:40

Same here. Thanks, I'm going to play with it more.

darwin12:01:42

alpha 13 actually

dottedmag12:01:25

Is there a way to tell REPL not to print function bodies? function cljs$core$object_QMARK_(x) would be more than enough to read the error messages.

rauh12:01:17

@dottedmag You can (set! js/Function.prototype.toString ... but no way back from it unless you save it somewhere

leov13:01:14

hihi. can I ask, how do I do CSRF protection with ring in case of ajax single page application?

leov13:01:40

I am already using ring-defaults with secure site defaults

mavbozo14:01:17

@leov when you generate the initial page, put the CSRF token inside <meta> tag in the html <head>. then before you ajax POST, grab that CSRF token from <meta> tag and put that in your POST data.

isak18:01:22

is there a good way to figure how much each dependency is contributing to the js output size (after advanced optimizations)

isak18:01:35

(other than commenting and recompiling)

tbaldridge19:01:51

@isak how much size are we talking about?

tbaldridge19:01:45

I've worked on applications that were 30MB of JS that after adv compilation + gzip ended up at 200KB or so.

dnolen19:01:48

@isak there’s just no good way to do that

dnolen19:01:22

@isak also dead code elimination makes your approach for testing that impractical

isak20:01:02

@tbaldridge : it was about 2-3 mb raw, then ~500 KB gzipped

isak20:01:21

@dnolen i see. yea i can see the pitfalls, also tested with module splitting.

tbaldridge20:01:51

@isak at times I've resorted to reading through the JS output and looking for anything that seems out-of-place. Like large string constants that someone has included for some reason, HTML that's been pasted into the source, etc.

tbaldridge20:01:00

I've also read through my deps list and tried to reason about what would possibly be creating large registries of references to functions that could otherwise be removed, but that also takes a lot of staring at a screen and thinking.

tbaldridge20:01:17

500KB seems pretty high though,

isak20:01:38

@tbaldridge : interesting, thanks

dnolen20:01:36

@isak module splitting is potentially even less reliable since the code split happens at fn level

dnolen20:01:10

@isak if you’re using a lot of foreign deps - there’s nothing you can do about that

isak20:01:09

@dnolen: yeah i have a lot of foreign deps (cljsjs stuff with externs). Just trying to get an idea of the sizes, so I can evaluate whether it is worth it to remove the dependency

dnolen20:01:49

just add up the min size of all your foreign deps

dnolen20:01:06

there’s no way to make that stuff smaller

dnolen20:01:15

Closure has no effect on that stuff

isak20:01:29

right, i see

dnolen20:01:16

a good rule of thumb - never use a foreign dep that you don’t absolutely need

dnolen20:01:36

if the functionality exists in Closure Library - you should always prefer it

Pablo Fernandez21:01:20

Why is react-toolbox/tab not being called in this piece of React code:

Pablo Fernandez21:01:19

That’s the definition of tab. I added a print statement there and it’s not being called.

Pablo Fernandez21:01:33

using the contents directly is a child of react-toolbox/tabs works though.