Fork me on GitHub
#clojurescript
<
2017-12-15
>
hagmonk00:12:58

@mfikes @thheller right, I'm trying to create a Grafana plugin, which is supposed to present a SystemJS compatible module when loaded, extend some AngularJS classes, and then expose those extended classes through module exports

hagmonk00:12:36

This is really in the weeds, for instance, merely including cljs-http - without even using it - is enough to break the plugin and prevent it from loading

hagmonk00:12:40

Using optimizations: none will also break things, as it results in calls to document.write ... the document has already been closed by this stage, so it effectively blows the entire page away. That's why I'm on whitespace optimizations (now using boot-cljs)

hagmonk00:12:11

I can export things by banging on js/Window, but now I'm trying to tidy things up and separate out the ugly JS+Angular interop stuff away from CLJS ... hence starting to use protocols.

hagmonk00:12:01

I want my implementation on the CLJS side to be "just implement these protocols and you're good" - seems like I have some hackery in the interop layer to make this as seamless as I hope

mfikes00:12:27

My first impression: Protocols aren't about interop. (Akin to the way that Clojure has a definterface that differs from defprotocol)

mfikes00:12:41

But, perhaps you can write an interop layer that does what it needs to do for interop purposes, but then makes use of ClojureScript types that satisfy certain protocols. (That is, if your goal is to have developers to produce ClojureScript that can "plug in" to the framework by satisfying those protocols.)

mfikes00:12:34

(The interop layer might be written in JavaScript, or some ClojureScript that plays the right games, making Grafana happy)

hagmonk00:12:12

That's exactly what I'm thinking now too. I took a number of wrong turns just feeling things out by trial and error, now I'm thinking of protocols as being the thing that makes the CLJS side easier to implement

hagmonk00:12:55

I'm pretty experienced with JVM interop, but this javascript stuff is really completely the wild west, it's kind of insane

hagmonk00:12:43

I've had to look at the bytecode and generated classes a couple of times on the JVM, but it's rare. Whereas here I was immediately confronted with that problem

hagmonk00:12:09

I think the right way to handle this will be to produce a JS artifact that is then imported into a separate JS file, which is then built by webpack or systemjs. Right now I'm trying to do everything in CLJS

justinlee17:12:18

Any recommendations for a favorite book or online reference that provides guidance for writing idiomatic clojurescript suitable for programmers with a bit more experience?

chris17:12:04

elements of clojure by ztellman

hagmonk17:12:06

@lee.justin.m I think Etudes for ClojureScript looks pretty good too

hagmonk18:12:57

Is it possible to start a boot-cljs-repl that is connected to a non-interactive browser runtime? Like Nashorn or headless Chrome? I want to unit test some CLJS code without spinning up a browser

martinklepsch20:12:18

@hagmonk I think that should be possible as long as that non-interactive runtime supports websockets

hagmonk22:12:57

@martinklepsch I'm thinking of hacking something together that works like boot-cljs-reload, except behind the scenes it starts chrome headless and sends across javascript via the devtools protocol ...

martinklepsch14:12:58

@hagmonk couldn’t you just use chrome-headless with boot-reload though? you can open an html file and it does support websockets and all that no?

hagmonk19:12:01

@martinklepsch yeah! that's what I'm doing for the time being ... just occurred to me that it would be good to cut out some extra ceremony. So you say "give me a REPL" and we fire up headless chrome, and just start shoveling compiled JS into it. No websockets or anything.

hagmonk19:12:33

@martinklepsch and there are additional benefits over doing the same thing with node, such as being able to capture screenshots, profile the browser ... the more I look at the devtools api, the more interesting it becomes

hagmonk20:12:02

@martinklepsch and now I just found https://github.com/tatut/clj-chrome-devtools, which looks perfect to run an experiment with ... and as an aside, looks like an exemplary modern Clojure project.

hagmonk22:12:03

might sound strange for web development, but I like to iterate in the REPL and run tests for the most part. Physically seeing what it looks like in the browser isn't the bulk of what I'm worried about

hagmonk22:12:36

but I'm coming from a Clojure + JVM mindset so that might color my thinking