Fork me on GitHub
#clojurescript
<
2016-01-15
>
j1mr10rd4n02:01:51

hi all, i’d like to do a quick straw poll on a question of style - i'm parsing a javascript message object e that contains a json serialization of an object of interest… are there any strong opinions on whether either of the following two forms are better/more idiomatic/more readable? (let [name (.-name (JSON.parse (.-message e)))] …) or (let [name (.. (-> (.. e -message) JSON.parse) -name)] …) I think i’m leading towards the second but the mixed use of .. and -> seems a little clunky - perhaps there's another way...

clumsyjedi03:01:13

@j1mr10rd4n: I personally would be inclied towards using aget - IE (let [name (aget (aget e “message") “name”)] …)

j1mr10rd4n03:01:55

@clumsyjedi: thanks for the input! that refactor made the line look as follows: (let [name (-> e (aget "message") JSON.parse (aget "name"))] …) which seems much better!

clumsyjedi03:01:01

yep, I like tht too

clojuregeek03:01:42

I have a library https://github.com/electric-it/clj-tosca .. which is just basically manipulating a data structure to describe a TOSCA document (standard for cloud instance) .. is it going to be easy to use in clojurescript?

samueldev04:01:52

so, I haven't followed this channel in awhile

samueldev04:01:01

but these last 2 weeks I've been back in clojurescript world, this time with re-frame

samueldev04:01:19

is om.next still the most popular or do people dig re-frame too?

cjmurphy04:01:08

@clojuregeek Those files are clojure files (.clj). They would have to be .cljc (or .cljx but that's an old standard) to be compatible in both Clojure and ClojureScript.

alexandergunnarson04:01:08

re-frame is awesome! Though I myself stick with "plain old" (read: awesome new) Reagent plus reactive DataScript via Posh.

mfikes04:01:29

Nearly all of that clj-tosca looks like it would compile as ClojureScript—the only bits that would need porting are the uses of clojure.data.json and clj-yaml.core

mfikes04:01:57

(You could even put those bits in :clj reader conditionals if not needed.)

alexandergunnarson04:01:50

Hey! Has anyone here used Figwheel with a mobile WebView? I'm not looking to go the React Native route for reasons of UI consistency.

alexandergunnarson04:01:25

As far as GitHub repos go, there's mobile + React Native + Figwheel, and mobile + ClojureScript REPL, but no mobile + WebView + Figwheel out there so far as I can see.

jaen08:01:03

@clumsyjedi, @j1mr10rd4n: FYI while aget works it's entirely by coincidence (read: Javascript's weak typing), it's meant to be used with arrays only; idiomatically you should be using https://closure-library.googlecode.com/git-history/docs/namespace_goog_object.html#goog.object.get and yes, I hate that it's not referred in by default as well.

jaen08:01:52

@samueldev: well, I'm not sure about "still" in that question - it seems to me re-frame has had been around longer than om.next being officially publicly available, so it couldn't have been more popular than re-frame always. And IMO I wouldn't call it popular now either - it's new, shiny, interesting, solves hard problems re-frame doesn't, but I'm not sure if those are the problems most of the community is having - I would rather say reagent and re-frame are still more popular than om.next because they are simpler and om.next advantages don't yet become apparent in a simple, CRUDy application.

jaen08:01:04

@clojuregeek: well, it's your library so how easy it is going to be to use from Clojurescript depends entirely on you. But like mfikes said the library seems to be fairly host-agnostic except the part where you serialise to json and yaml. Serialising to JSON with Clojurescript should be easy, something like (comp #(. js/JSON stringify %) clj->js) should do the trick. It's probably going to be a bit hard with the yaml format, but it seems there's that lib that could help you - https://clojars.org/cljsjs/js-yaml

ricardo11:01:31

@samueldev: If you’re counting votes, I prefer re-frame. I think Om.Next has more mindshare though.

meow13:01:25

agnosticism

meow13:01:51

sharing is caring

edbond14:01:49

how to minimize compiled file in advanced mode?

dnolen14:01:50

@edbond: what do you mean?

edbond14:01:14

the compiled file is quite large.

dnolen14:01:48

use advanced mode, make sure pretty printing is disabled, use gzip

edbond14:01:50

is there a way to find what lib takes more space?

dnolen14:01:54

that’s about all you can do

dnolen14:01:02

there is no way to do that no

dnolen14:01:15

measuring the size of the file before gzip is not productive though

edbond14:01:54

it's 113k gzipped, reagent, core.async, dommy and cljs-http

edbond14:01:07

ungzipped 411k

dnolen14:01:13

113K seems perfectly reasonable given React (40K) and the standard lib (30-40K)

dnolen14:01:35

we’re talking about a medium size image here

delaguardo14:01:31

@edbond: use :output-dir compiler option and inspect compiled code in this directory

dnolen14:01:21

@delaguardo: that’s not as informative as it would seem because of dead code elimination.

delaguardo14:01:41

right, but it may give a hint

dnolen14:01:09

@edbond: if you’re interested in minimizing initial payload then Allen Rohner’s talk from the last conj is informative, esp. the first 10-15 minutes https://www.youtube.com/watch?v=fICC26GGBpg

dnolen14:01:29

Closure has long supported code splitting and defferred loads

clojuregeek15:01:59

@cjmurphy: thanks!! I thought that might be the case.

scriptor18:01:42

does anyone here know if quiescent (https://github.com/levand/quiescent) has a slack or IRC channel somewhere?

Alex Miller (Clojure team)19:01:18

not to my knowledge but you can pm @luke

billharten19:01:12

Does anybody have https client functionality working in clojurescript? What libraries?

jeremys19:01:05

@billharten: Hey Bill cljs-ajax might be what you’re looking for https://github.com/JulianBirch/cljs-ajax

kamn22:01:04

On http://clojure.org is you scroll down a little you have a list of very general Features

kamn22:01:32

Is there something similar for ClojureScript?

kamn22:01:48

On the site or cljs wiki

Alex Miller (Clojure team)23:01:47

I think they are the same except s/jvm/js

Alex Miller (Clojure team)23:01:17

I guess they vary a bit re concurrency and macros

mfikes23:01:14

This pages collects the differences that ClojureScript has from Clojure: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure

mfikes23:01:33

Oops. Missed that had been mentioned 😉

kamn23:01:54

@alexmiller: I brought it up because I was talking to my boss about cljs

kamn23:01:59

mainly because there is a greater (though small) chance at using cljs then clojure

kamn23:01:19

I quickly realized that there is not a quick way for non-devs to read about the virtues of clojurescript

kamn23:01:53

non-devs is the wrong term

shaun-mahood23:01:51

@kamn: What does your boss need to see to get cljs going?

kamn23:01:37

It was a side conversation about potential future products and I wanted to get it in

kamn23:01:44

get it mentioned*

shaun-mahood23:01:53

And what size business/project is there a potential for? We might be able to come up with some good examples that will help

kamn23:01:34

I don't think it is at that phase yet

kamn23:01:25

It was just some water cooler chat and I mentioned how much I liked it and specifically tooling

kamn23:01:19

I guess what I am looking for is something to show technical, non-clojure people why CLJS is a great choice without them having to understand the benefits of Clojure first

shaun-mahood23:01:22

Yeah the tooling is pretty fantastic now. I've found a couple areas that have really impressed our non-dev managers so far - main things have been excel-templates for reporting and figwheel to change things during spec meetings

kamn23:01:59

and I realize that might not be possible since the high similarities between the languages

kamn23:01:06

Yea I showed off part of the figwheel talk from the last clojure/west

shaun-mahood23:01:22

I'm thinking about putting in a proposal for the next Clojure/West on adoption and successes of Clojure in our small-ish (100-150 person) business with only one dev - would that be interesting or useful to you? Even if it doesn't work out as a full talk I'll have a bunch of info and thoughts I can send to you if you want.

kamn23:01:28

I think a lot of people would be interested in a talk like that

kamn23:01:52

and yes I would love any material or tips!

shaun-mahood23:01:19

Ok cool! Hopefully I'll be able to get a whole good talk out of it, but if not I'll send you what I can get together.

kamn23:01:52

I am planning to go to Clojure/West so hopefully I will you give the talk

shaun-mahood23:01:52

Oh awesome - really hoping I can make it there even if I don't give a talk. I went to last year's Conj and it was awesome.

shaun-mahood23:01:25

Just realized I used awesome twice in the same message, friday afternoon brain is apparently kicking in.