Fork me on GitHub
#clojurescript
<
2015-12-07
>
underplank04:12:07

Hi all. I was wondering if there is a way to get auto-completion of namespaces and vars in the figwheel repl?

pesterhazy11:12:34

richiardiandrea: at any rate, big thumbs up for replumb! here's what we ended up building using bootstrapped cljs: http://landofquil.we-do-fp.berlin

thheller11:12:02

@darwin why are you using so many macros in chromex?

darwin11:12:55

@thheller: hm, flexibility? also the generated code is not so verbose

thheller11:12:18

macros make the code much less flexible in my experience

darwin11:12:25

I started generating them without macros, but that led to a lot of “templating” work

darwin11:12:48

well, maybe we could discuss specifics, I know about the problem that once you step into macro land you have to stay there, but this does not seem to be a problem for chromex

thheller11:12:36

I have this idea for a cljs devtools extension that provides a repl, namespace browser, test runner etc

thheller11:12:29

started fiddling with some chrome ext stuff

darwin11:12:38

I have also some ideas for this, just wanted to start hacking on it today simple_smile

darwin11:12:46

maybe we should join forces simple_smile

darwin11:12:16

I’m going to fork blink devtools and add missing cljs bits

thheller11:12:40

well I started a few months ago but only have very limited time at the moment

darwin12:12:00

and provide a way how to run standalone chrome instance with this devtools fork + some extension to aid cljs development

darwin12:12:08

cljs-devtools will be a big part of it

thheller12:12:20

I really want it to work outside chrome though

thheller12:12:47

so my idea currently is to use a normal SPA for the devtools stuff

thheller12:12:02

and just load that via an iframe or something into the chrome devtools

thheller12:12:09

eg. create a tab for it

thheller12:12:24

so the devtools stuff is not integrated into the actual page

thheller12:12:45

basically as a remote to the browser window

thheller12:12:12

none of it works anymore

thheller12:12:21

but the devtools tab was easy enough 😛

thheller12:12:44

only reason do hook it into devtools really is to have it side-by-side with the browser window

thheller12:12:48

at least for me

darwin12:12:27

I see that you are using apis to inject some code into inspectedwindow

darwin12:12:40

how that would work without chrome extension apis?

darwin12:12:45

in a different browser?

darwin12:12:59

you would open an iframe with access to parent?

thheller12:12:22

basically yes

thheller12:12:28

it is all driven by the server process

thheller12:12:33

since you really need access to the compiler

thheller12:12:47

so shadow-devtools sort of acts as a gateway

thheller12:12:01

(using shadow-build to compile stuff)

darwin12:12:16

IMO we should first focus to make best experience in chrome/devtools and maybe later think about supporting other platforms

darwin12:12:36

I’m planning to use figwheel for this

thheller12:12:45

I really want it to work without chrome

darwin12:12:46

I will connect to its REPL

thheller12:12:58

eg. mobile browser but devtools on desktop

thheller12:12:23

shadow-devtools has a REPL and figwheel-ish features built in already

darwin12:12:37

chrome has remote debugging, it will work in my scenario of devtools fork

thheller12:12:42

just need to put a prompt somewhere 😉

darwin12:12:53

I will put prompt into js devtools console

darwin12:12:57

prefixed by >

darwin12:12:19

will do color coding if you are executing cljs stuff or plain js stuff

darwin12:12:42

it will send the command to figwheels via nREPL and echo results back, presented by cljs-devtools

darwin12:12:37

with that devtools fork, I can optionally inject cljs-devtools support and this figwheel REPL integration into js context automatically

darwin12:12:03

so people don’t have to set it up in their projects (but this is not a big priority)

thheller12:12:47

that is one of my biggest priorities 😛

darwin12:12:48

also I will present figwheels, warnings and compilation errors in this separate chrome/devtools instance

thheller12:12:07

I do not want dev related code in my code

thheller12:12:25

always worried it ends up in production 😛

darwin12:12:53

the problem with this automatic approach is versioning, the code needs to be compiled agains some version of clojurescript, which one?

darwin12:12:59

what if there are breaking changes?

thheller12:12:33

I consider caching a solved problem in shadow-build

thheller12:12:38

so there should never be version conflicts

darwin12:12:24

caching? Let me rephrase, cljs-devtools is implemented in cljs and has to be compiled, if I’m about to provide it automatically and inject into js context of running cljs app, I have to know which version of cljs compiler/library they used for the app, so cljs-devtools code snaps with it

darwin12:12:54

this is a theoretical problem, most of the time this is not an issue, but it could be

thheller12:12:04

run lein run -m build/dev-repl

thheller12:12:16

this starts a REPL and figwheel-ish reloading

thheller12:12:22

without any modification of cljs code

thheller12:12:36

same could be done for cljs-devtools

thheller12:12:43

let the build tool handle it

thheller12:12:02

eg. say 'inject-cljs-devtools' and be done with it

darwin12:12:01

ok, if you have control over the build that this is good approach, but in my model I don’t, I let people use whatever build tooling they wish

darwin12:12:20

I don’t care

thheller12:12:40

but you really need support from the build tool for some stuff

thheller12:12:52

can't do it all via the REPL

darwin12:12:20

depends on goals, my goal is to aid clojurescript development/debugging on client side, user has to have his own nREPL for devtools to connect to it, same with error/warnings reporting, there must be some “provider"

darwin12:12:32

in first iteration I will use/bend figwheel for this

darwin12:12:53

but people can provide their own “providers”, devtools will connect to them as clients

darwin12:12:22

so I don’t care that much how the code is compiled/built, the provider will have to tell me important events

darwin12:12:24

same with testing, I’m going to write my own test reporting, but there must be something like karma, to report which tests were ran/failed

mcgivernsa12:12:14

this is probably due to my poor google skills, but I can't find what differences are expected between JDK versions in advanced compilation output

darwin12:12:19

I believe this all can be implemented into figwheel as proof-of-concept, and later broken into independent tools, if it can fly

thheller12:12:52

mcgivernsa: no differences really

mcgivernsa12:12:54

I get different files on compiling the same project with the Oracle JDK and OpenJDK

thheller12:12:23

different how?

mcgivernsa12:12:36

but because it's advanced compilation output it's hard to tell

mcgivernsa12:12:43

the file contents are different

mcgivernsa12:12:03

the behaviour of both files seems the same

mcgivernsa12:12:21

might be a closure issue, just not sure if there's somewhere I can look before I try to create a minimal repro

thheller12:12:55

never checked how stable the naming is

thheller12:12:09

but one run might be different from another even on the same jvm

thheller12:12:33

since closure renames everything

thheller12:12:39

as long as everything works that should not be a problem

mcgivernsa12:12:54

I get consistent results on different machines with the same version, I guess I was expecting builds to be reproducible

dnolen12:12:47

@mcgivernsa: pretty sure there are no such guarantees that builds will produce the exact same source

mcgivernsa12:12:23

Ok, that's fine too 😃

thheller12:12:46

@darwin: interesting stuff in cljs-devtools, never knew about custom formatters ... quite hard to find docs for it 😛

thheller12:12:02

yeah I found that link buried in a chromium issue somewhere

darwin12:12:33

yep, one has to follow chromium issues and their IRC channel, ideally

darwin12:12:45

there is some interesting development by some TypeScript guy from Microsoft, but I don’t want to wait for it anymore, the process it too slow and not necessarily fitting my ideas: https://code.google.com/p/chromium/issues/detail?id=484261

darwin12:12:18

his vision is too grand, he wants to turn devtools into an IDE for TypeScript

darwin12:12:01

some pieces of it could be repurposed for clojurescript, but it is not clear how (at this point)

darwin12:12:14

my original idea was to build an electron app, which would host devtools fork, but there is a better approach, I believe now: http://www.nowherenearithaca.com/2013/12/setting-up-debugging-of-chrome-devtools.html

darwin12:12:29

you can run chrome and point it to your version of devtools frontend

darwin12:12:23

that is better beceause Electron does not have Extension APIs available as they are in the full chrome, so you cannot really run devtools extensions or arbitrary chrome extensions in electron

darwin12:12:14

it is not that bad, to require people to run another isolated instance of Chrome Canary as their “Electron-like” app hosting this cljs-devtools tooling, with all possible whistles

darwin12:12:55

and I don’t have to maintain binary releases of packaged Electron app, they just go and grab latest Chrome

darwin12:12:01

@thheller: do you know about cuttle? https://github.com/oakmac/cuttle, I'd to integrate something like this later

grav13:12:14

ok, so I have this nice, expressive language called EDN. Then I want to talk to my endpoint using GET. What do I do?

grav13:12:16

According to the http spec, I’m not allowed to encode the EDN in the body of a GET request. The other alternative is to serialize everything as query parameters, but that just seems like a wasteful mapping

thheller13:12:41

@darwin cuttle is nice idea although at the moment I'm trying to reduce the apps/windows I have running

thheller13:12:58

that doesn't fit too well with my goals

thheller13:12:17

my setup now is cursive+repl + browser/devtools open

thheller13:12:25

not sure I like the idea of hooking directly into the devtools console

thheller13:12:52

maybe with parinfer

thheller13:12:39

@grav: if the data is small enough encode edn->base64 and just put one param into the url to GET

thheller13:12:41

works reasonably well with smalls maps

darwin13:12:57

@thheller: that is my setup as well, I just make repl available in devtools as well, and start displaying figwheel’s alerts there too, plus improve some aspects of devtools (inline evaluated values will use custom formatters for example)

thheller13:12:39

yeah I just tested cljs-devtools, seems to have some issues with large values

thheller13:12:44

but besides that it is pretty nice

darwin13:12:19

I’m not aware of any issues with large values, bug reports welcome simple_smile

thheller13:12:39

I just console.log my app-state which is a map with records as keys and maps as values

thheller13:12:12

so the preview is multiple lines long

thheller13:12:32

confusing stuff happens when clicking the arrows

thheller13:12:57

will try more later, got some work waiting 😛

bensu14:12:16

@grav are you familiar with ring and compojure?

grav14:12:34

@bensu Yes, we’re using Compojure, but I’m a newbie

grav14:12:24

@thheller - but then it just seems easier to use a POST, where I can rely on transit encoding and decoding stuff

bensu14:12:59

@grav are you trying to figure out how to talk to an existing endpoint, develop and endpoint, or both?

bensu14:12:05

@grav ok, assuming the correct verb is GET, what parameters does the endpoint need?

grav14:12:05

It might need something like {:created some-date :location some-location}, where both some-date and some-location might be ‘rich’ data types

bensu14:12:57

rich as in arbitrary edn?

grav14:12:02

yes, exactly

grav14:12:29

My “problem” is that it seems wasteful to invent my own serialization

bensu14:12:14

if you use something like https://github.com/JulianBirch/cljs-ajax and pass your map as :query it will serialize it

bensu14:12:36

I don't know if that is a good idea though, because you'll be left with monstrous urls

bensu14:12:10

I think https://github.com/r0man/cljs-http has the same funcitonality

bensu14:12:03

on the other side, you'll need https://ring-clojure.github.io/ring/ring.middleware.params.html#var-wrap-params to decode the params and get them as clojure data

underplank15:12:17

Hi all, I’ve been looking at re-frame for a SPA. I really like the event driven pipeline, but would prefer to just use type-1 reagent components, instead of type-2 and the reactions etc. Is there a really good reason I couldnt just use the type-1 components?

martinklepsch16:12:30

@underplank: with type 1 components your subscriptions will always get re-created while rendering causing computation overhead

polymeris16:12:37

Hi all. Looking for a clientside DB. Found https://github.com/tonsky/datascript . Are there other alternatives you could recommend?

dnolen16:12:40

@polymeris: that’s the most popular and most mature solution

underplank17:12:32

@martinklepsch: Ahh, so its an optimization then? In practice is it needed? Im just trying to weigh up the optimization with the simplicity of type-1 components.

underplank17:12:48

I guess if they put it in there then its probably needed 😉

jaen17:12:24

@underplank: it's not exactly an optimization

jaen17:12:33

It's for the cases when you need state to persists across renderings.

martinklepsch17:12:33

@underplank: there’s also #C073DKH9P btw

jaen17:12:39

Internal to the component.

underplank17:12:54

Oh! I didnt realize that. I might go and ask over there.

underplank17:12:36

@jaen: Right, so in some cases its used for that. But for re-frame and subscriptions (i think thats the right thing) its a pattern that they advise.

jaen17:12:20

Then I suppose you could call it an optimisation of sorts - you don't want to repeatedly call subscribe and create a reaction if you can do it only once.

underplank17:12:52

@jaen: Right. I was thinking of replacing the subscribe functionality with something else. And im basically trying to work out the tradeoffs atm.

underplank17:12:20

Mainly because I think the type-1 components have a much easier testing story than the type-2.

underplank17:12:05

Unless im missing something. It seems to get the datastructure out of type-2 I need to jump through more hoops.

jaen17:12:22

Quite possibly, I royally suck at testing so I unfortunately can't offer more help in that regard.

jaredly18:12:26

Is there a way to enable-console-print! that is valid for within go blocks? Or basically just a way to set *print-fn* globally?

thheller18:12:10

enable-console-print! is global

jaredly18:12:44

hmmm it doesn't seem to be. I'm working w/ cider + figwheel, and I call enable-console-print! and then try to do prn in a go block, and it throws an error

jr18:12:46

(.log js/console (pr-str %))

thheller18:12:29

does it work if you call enable-console-print! and prn directly after?

thheller18:12:41

figwheel might be setting its own print-fn, not sure

grav18:12:48

@bensu: thanks for the links! I’m currently using POSTs only. Very un-restful but apart from that it seems I get a lot of other stuff for free ...

jaredly18:12:31

thheller: well yes, if they're both within the go block. But the error is no *print-fn* defined, so that's not the issue

thheller18:12:10

you call it inside the go block?

jr18:12:56

why are you prn inside of your js code? figwheel does not eval that code

jaredly19:12:48

@jr b/c I'm a noob and don't know what else to do 😄

thheller19:12:06

I do prn debugging all the time

thheller19:12:24

works really with live-reloading too

jaredly19:12:31

thheller: if I do (enable-console-print!) (go (prn (<! c))) then it doesn't work. If I do (go (enable-console-print!) (prn (<! c))) then it works

thheller19:12:48

thats odd, it is a set! not a binding, so it should work wherever

thheller19:12:59

is that at the top level?

thheller19:12:13

or somewhere something else might be using a binding?

thheller19:12:22

eg. figwheel repl invoke?

jaredly19:12:19

I'll try putting it at the top level

justin80820:12:56

As part of the recruiting process for devs for an upcoming client project my firm will do, I’m looking for some sample code that converts what we’re doing with React + Ruby on Rails to Om-Next (or some other ClojureScript project): https://github.com/shakacode/reactrails-in-om-next-example/blob/master/README.md

dnolen20:12:23

@justin808: probably a bit too early to try that with Om Next seeing that we’re still in alpha simple_smile

dnolen20:12:17

also reagent (and the re-frame approach) is quite popular and worthy of assessment

justin80820:12:14

@dnolen: Thanks for the advice! How soon do you think we can do such an example?

dnolen20:12:42

@justin808: probably late December or early January

dnolen20:12:03

there's some pretty major feature issues blocking a beta

dnolen20:12:20

@justin808: if you’re interested in following along there is an #C06DT2YSY channel

justin80820:12:30

Thanks! My firm is doing lots in the react and Ruby on Rails space (http://www.shakacode.com) and we’re looking to support Clojure as well for our clients.

darwin20:12:20

is there any nREPL client implementation in clojurescript? I want to connect to nREPL session from a web page.

darwin20:12:00

@richiardiandrea: they don’t implement nREPL, they have some custom API for evaluating commands

darwin20:12:13

I need proper nREPL client library implemented in cljs (not in clojure)

richiardiandrea20:12:36

oh, that's different yes

richiardiandrea20:12:32

sorry about that, the only thing I can think of is Figwheel, which connects to nRepl with some fiddling but I don't know the innards

darwin20:12:00

figwheel is nREPL server, and does that on server-side

thheller20:12:05

don't think there is a nrepl client

darwin20:12:05

so it is implemented in clojure

darwin20:12:15

the closest so far is https://github.com/maxbrunsfeld/nrepl.js, will probably use that for now

darwin20:12:27

would be nice to have cljs implementation eventually

justin80820:12:53

https://github.com/shakacode/reactrails-in-reagent per @dnolen’s advice…Great way to get our attention, if you have the time.

justin80820:12:10

Our recruiting is based heavily on open source contributions and blog articles.

justin80820:12:20

Works great for a remote-first team.

thheller20:12:27

I hope socket REPL becomes popular soon, nREPL is not fun to work with

darwin20:12:11

My current goal was to connect to Figwheel's nREPL, I don’t want to implement nREPL client in clojurescript (seems like a bit of work which will become obsolete soon-ish)

darwin20:12:50

I will probably cheat here and introduce new protocol into figwheel and use it as REPL command delivery for now

danielcompton20:12:43

@dnolen: would you be interested in tests covering other compiler config options similar to https://github.com/clojure/clojurescript/commit/53fd5991a41f49e7dffdd891c445f48f0835e223?

dnolen20:12:13

@danielcompton: yep any and all tests welcome simple_smile

dnolen20:12:21

while we have good coverage of the ClojureScript runtime bits

dnolen20:12:31

we’re sorely lacking in terms of actual compiler tests

danielcompton20:12:43

yeah, I did notice that … 😊

eggsyntax21:12:15

Can anyone recommend a minimal, up-to-date cljsbuild-based template? I just need to put together an example project for something, and in this case it'll be valuable to have it use cljsbuild (otherwise I'd use Mies).

bensu21:12:52

@eggsyntax: the figwheel template comes with cljsbuild and it's fairly up to date

eggsyntax21:12:38

@bensu: thanks. Not as minimal as I hoped for on this one, as much as I love it & use it for everything.

bensu21:12:28

@eggsyntax: it will probably take you more time to look after the template than to delete the extra stuff from figwheel's project.clj, it has only three extra deps after all.

eggsyntax21:12:47

Actually, taking a fresh look at it, it's pretty damn minimal. I'd misremembered. I'll go with it. Thanks, good call!

eggsyntax21:12:38

Either Bruce has simplified it further in the last six months, or my memory's going. Or both 😉

bensu21:12:33

@eggsyntax: no problem. it might be that it has options to add stuff, without them there isn't much besides figwheel.

noonian21:12:03

it has options for om and reagent but they hardly do more than add the dependencies

bensu21:12:33

hahaha @noonian: don't short sell them, I added those options simple_smile

noonian21:12:41

@bensu: hah! Well, I use them and I like that it’s a minimal template.