Fork me on GitHub
#clojurescript
<
2015-07-01
>
mj_langford00:07:21

Look a ClojureScript livecoding stream: https://www.livecoding.tv/wildermuthn/

mj_langford00:07:05

which of course ends 2 minutes after posting it 😄

markstang03:07:28

OK: Create a nil version in the app-state, observe that in your component, every time it changes your component will get called.

jrychter09:07:41

What do people use in larger ClojureScript applications for splitting the system into components and managing their startup? Any practical advice?

danielcompton09:07:02

@jrychter: namespaces and libraries? Not quite sure what you mean

jthomson09:07:32

@jrychter: for handling run-time state, there is a fork of Component for clojurescript (https://github.com/quile/component-cljs), or you can roll your own with a start/stop protocol or multimethod. If you mean splitting the codebase into separate js files check out http://swannodette.github.io/2015/02/23/hello-google-closure-modules/

agile_geek09:07:25

@jrychter: very, very early days but you could look at YoYo https://github.com/james-henderson/yoyo

cfleming10:07:13

Are the Google Closure library demos hosted anywhere?

cfleming11:07:01

Actually I just figured out they’re easy to see by cloning the repo - no compilation or anything required.

jrychter11:07:09

@daniel: I was thinking about something along the lines of Stuart Sierra's component.

jeluard13:07:34

cljs.core/uuid now conflicts with user defined uuid. Is that expected?

andrewmcveigh13:07:24

@jeluard: cljs.core/uuid is a fairly recent addition, so maybe.

jeluard13:07:40

There is no equivalent in Clojure so I was wondering.

dnolen13:07:24

Core can always take a name

bostonou13:07:59

I'm sure it's been mentioned, but @mfikes cljs ios repl is awesome! https://github.com/mfikes/replete/wiki/Beta

bostonou13:07:16

@petrus: if you're still looking for some humanize help, might be useful to you - http://clojurescriptmadeeasy.com/blog/how-to-humanize-text-cl-format.html

scttnlsn14:07:31

How can I pass environment info into a ClojureScript build? i.e. API URL for development vs. production

scttnlsn14:07:14

(I’m using Leiningen + cljsbuild)

dnolen14:07:39

scttnlsn: lein-environ + a macro is one way

scttnlsn14:07:46

OK, thanks guys

meow18:07:52

so it looks like cljs does not expose goog.dom.ASSUME_STANDARDS_MODE as a compiler option. True? Is that a missed opportunity? The closure book indicates that setting that to true (if you can make that assumption for your app) would reduce compiled code size and improve runtime performance.

coyotespike18:07:44

I'm puzzled about how I'm converting and sending JSON.

coyotespike18:07:58

First, I cljs-ajax/POST with {:format :json} to the server, where I thought ring-json/wrap-json-body would convert it back to Clojure before storing in Redis with Carmine. Then, I cljs-ajax/GET with {:response-format :json}, where I thought wrap-json-response would convert back to Clojure, or something. The weird part? As you can see below, I have to use transit-cljs to convert ClojureScript map to JSON and vice versa on the client side, and then use cheshire/(generate-string) server-side.

coyotespike18:07:51

I'm just sending and retrieving a map. Here's how I POST:

(def w (t/writer :json-verbose))

(defn json-writer [thing]
  (t/write w thing))

(defn save-stuff []
    (let [value (subscribe [:app-db])
          jvalue (json-writer @value)]
      (ajax/POST "/submit2" {:params jvalue
                             :handler handler
                             :format :json
                             :keywords? true})))

dnolen18:07:08

pkobrien: ClojureScript exposes :closure-defines compiler option for this.

coyotespike18:07:23

And here's how I GET, with (generate-string) on the server side:

(def r (t/reader :json-verbose))

(defn json-reader [json]
  (t/read r json))

(defn new-merge [response]
  (let [new-map (map-reader response)]
  (js/console.log new-map)))

(defn get-stuff []
  (ajax/GET "/submit" {:handler handler 
                       :error-handler error-handler 
                       :response-format :json
                       :keywords? true}))

coyotespike18:07:36

Is this standard, or have I missed something?

dnolen18:07:22

@meow: that said the Closure book is from early in the JS engine arms race, the performance stuff may or may not apply. Code size probably, but only if you’re using goog.dom heavily of course. Which you likely won’t be with a React binding library.

meow18:07:24

@dnolen: cool, thanks!

dnolen18:07:51

@meow: https://github.com/clojure/clojurescript/wiki/Compiler-Options is a good place to look if you’re looking for a hook for some Closure feature

meow18:07:33

@dnolen: I did look there but :closure-defines didn't jump out at me and I guess I lost my focus by the time I got to the bottom of the page. But now I know, thanks. simple_smile

meow18:07:22

And good point about the react bindings negating a lot of the goog.dom performance potential.

meow18:07:11

But the code size should still go down.

dnolen18:07:24

@meow: yes, but only if you actually use goog.dom. goog.dom is not something that’s required by default

meow18:07:36

I'm using [goog.dom ViewportSizeMonitor] and (dom/getDocumentHeight)

dnolen18:07:49

right in that case yes

meow18:07:07

so by setting goog.dom.ASSUME_STANDARDS_MODE at compile time will allow Closure to dead-code eliminate all of its quirks mode support code.

meow18:07:42

so I should see a benefit even when I only use a couple of little functions

dnolen18:07:02

though I can’t imagine it will be all that detectable

dnolen18:07:00

I’d expect cljs.core and other libraries etc. to dominate your final size until your application gets very large.

jwm18:07:22

mini poll: how many people use reagent vs om?

jwm18:07:05

I found re-frame it looks interesting for SPA dev

roberto18:07:09

I’m using reagent, but only because it was easier to get started with.

sveri18:07:17

om -> reagent, maybe to om next if it turns out to have advantages

sveri18:07:22

re-frame sits on top of reagent

jwm18:07:37

I noticed it used reagent

roberto18:07:39

i started playing with re-frame yesterday

jwm18:07:55

also figwheel has simple plugins for both so that is cool

roberto19:07:07

ran into some issues when trying to trigger xhr events across different event handlers

coyotespike19:07:06

Reagent with re-frame.

jwm19:07:02

anyone have any projects using both on github?

jwm19:07:09

reagent and reframe I mean

jwm19:07:43

on an unrelated subject yo-yo looks cool

meow19:07:45

I'm using freagent (with an "f") because it lends itself to this app. Looking forward to om.next.

spiralganglion19:07:03

I played with re-frame a bit and enjoyed it. Looking forward to seeing om.next.

meow19:07:54

Lots of reactive options for cljs - very exciting times

meow19:07:14

should allow us to quickly move beyond reactive rendering and onto more interesting concerns

jwm19:07:13

yeah I am trying to reimagine some large system done using drupal 7 for a long time friend

jwm19:07:27

I was thinking of graphing all of it first and then building it into a rest / microservices layout

jwm19:07:46

might as well throw react at it as well

meow19:07:03

(goog.userAgent/getUserAgentString) says I'm "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36" which seems like a wild guess

meow19:07:33

I guess Google isn't that familiar with Chrome...

dnolen19:07:35

pkobrien: try the goog.userAgent.product namespace

meow20:07:24

@dnolen: Yep, looked there as well. I'm just picking the low-hanging fruit from the various goog namespaces. Was just surprised at the user agent string.

dnolen20:07:18

@meow: lots of browsers lie and do stuff like that, it’s pretty much standard

meow20:07:33

lies, browsers, and statistics

jwm20:07:03

I’d place browsers after statistics even simple_smile

chriscroxton20:07:17

Im working on my first cljs project, are there any recommendations for a simple lein template with a repl?

dnolen20:07:45

@chriscroxton: not the shortest path, but before using a template I strongly recommend learning how to do a basic thing from scratch. It will save you an incredible amount of time later when you inevitably outgrow the template.

dnolen20:07:07

@chriscroxton: do you need a webserver? And what text editor are you using?

chriscroxton20:07:24

@dnolen: Working from scratch does make sense as I am new to the language. I am looking at creating a library for http://parse.com, I would need a webserver and I am using IntelliJ with Cursive plugin

chicoxyzzy20:07:51

same problem! and I use Cursive too

chicoxyzzy20:07:14

I think this is good place to start if you are going to try Om https://github.com/omcljs/om-cookbook

chriscroxton21:07:29

I will be using Om in my the app, but first I want to create a basic library for the Parse functionality

dnolen21:07:50

@chriscroxton: have you worked through the Quick Start?

dnolen21:07:06

Cursive does eliminate a lot of issues around REPL integration - it’s easy there.

chriscroxton21:07:48

@dnolen: I have, I was planning on working off that if a template was not recommended

chriscroxton21:07:06

I guess that is the leanest approach which is what I am after

jwm21:07:10

have you seen reagent

jwm21:07:32

I was asking earlier about which people use and reagent seemed to kind of be the more popular

spiralganglion22:07:31

Well, the number of respondents was rather few. If you look at, say, GitHub stars, Om seems to lead by a long shot.

dnolen22:07:33

Om has a lot stars due to being the first of its kinda over React, there’s was a ton traffic to my blog post on it in early 2014

dnolen22:07:48

something like 150,000 page views in under a week or something

dnolen22:07:05

so I wouldn’t take stars as an indicator of usage.

dnolen22:07:38

based on mailing list questions, Slack, and IRC I believe Reagent has a very strong following comparable, if not larger than Om.

jwm22:07:14

I haven’t done a project yet in either just read synopsis and it seems like reagent is a bit cleaner

arohner22:07:40

I don’t suppose anyone has an example of injecting a CLJS repl into an arbitrary web page using a static JS script?

dnolen22:07:11

@arohner: is this for development?

dnolen22:07:09

why can’t you use the :output-to script that ClojureScript generates?

dnolen22:07:19

or modifying it

dnolen22:07:32

the main issue is just making sure the page can load the :output-dir files from the right place

meow22:07:15

@arohner: did you want a command-line repl associated with your web page for development, or an interactive repl inside of your web page itself?

arohner22:07:46

@meow: command line repl

meow22:07:56

ok, just checking

meow23:07:15

@jwm and @ivanreese: I have looked at all of the reactive tools for cljs and they all have their unique characteristics that some folks like and other folks don't. There is #C06DXGSBU for comparing and discussing alternatives.

meow23:07:38

It's pretty easy to read about each, go through their tutorials and examples, and decide for yourself. Each one helps you learn the overall concepts even better and I don't think it's really a waste of time even if you select a different tool.

meow23:07:04

Even better, the project maintainers are very mature and there isn't really any feuding or unhealthy competition in this area. If anything, a lot of good ideas are shared among all the projects.

chicoxyzzy23:07:23

hmm.. I am following Quick start tutorial and got an error here https://github.com/clojure/clojurescript/wiki/Quick-Start#browser-repl after >Require your namespace by evaluating (require '[hello-world.core :as hello]). I got > java.lang.IllegalArgumentException: Namespace hello-world.core does not exist only one difference that my project is called om-test not hello-world but my namespace in src/om-test/core.cljs is ns hello-world.core can I somehow fix that issue without renaming directories?

chicoxyzzy23:07:56

all previous examples from tutorial work fine