Fork me on GitHub
#clojurescript
<
2016-10-13
>
darwin00:10:46

@mx2000 it looks like you REPL is talking to rhino...

darwin00:10:50

well, your configuration is probably wrong, I assume you wanted to use browser+figwheel, not headless rhino javascript interpreter

darwin00:10:38

I have no experience with vim+fireplace

mx200000:10:41

Browser code reloading works with fighweel.

darwin00:10:04

how did you start cljs-repl with piggieback?

darwin00:10:30

I’m afraid you or someone you called, used (cljs.repl.rhino/repl-env) as your REPL environment

darwin00:10:12

so your piggieback is trying to use rhino as execution target for your REPL, which is somewhat broken in your setup, but that is a separate issue

darwin00:10:26

because that is not what you wanted to do in the first place 🙂

mx200000:10:29

Hmm , all really complicated

mx200000:10:43

I had it working before some weeks ago , I just called :connect .. and it worked

darwin00:10:45

I’m sorry, this stuff is pretty complicated and you should build a mental model to be able to troubleshoot problems

darwin00:10:46

you may try to read this to visualize what might've gone wrong, but it is not specific to your case: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md

darwin00:10:52

the problem is probably in the point where cljs repl is being created via piggieback, the repl-env is probably wrongly configured

shaun-mahood00:10:18

@dnolen: Thanks for the help 🙂

richiardiandrea00:10:49

Hello everybody, a question: is clojure.spec.test/instrument already operational in cljs? Does it check the arguments when I pass a function in? I am on alpha10 at the moment.

herbm02:10:20

In a clojurescript figwheel REPL what namespace has the "use" command -- I can't use swap! or even use and need to use the right namespace to get something workable -- emacs cider started this REPL

herbm02:10:53

ok, found namespace cljs.user -- cider repl report itself as " Figwheel: Starting server at http://localhost:3449" on start, but I can't tell if it is really connected. swap! and most symbols seem to be missing -- first time I might have be connect in this environment...

ag02:10:38

@herbm figwheel needs a javascript environment - you have to open a webpage in the browser. then it will connect. You can test if it’s indeed connected by issuing something like (js/alert)

herbm02:10:54

#ag thx -- in this case the js is in ANdroid with React Native

herbm02:10:49

No such namespace as js -- only namespace seems to be cljs.user

ag02:10:14

same thing - you need to have something running in emulator

ag02:10:22

or on the device via adb

herbm05:10:22

Got it to work -- Emacs/Cider to figwheel to android (and from Windows dev box) -- thanks to #Doglooksgood

tengstrand06:10:39

I want to run a REPL while using Figwheel. I followed these instructions: https://github.com/bhauman/lein-figwheel. I installed rlwrap and then executed : rlwrap lein figwheel. Figwheel starts up as before, and ends with the message: Successfully compiled "resources/public/js/client.js" in 19.279 seconds. The REPL doesn’t start up. I’m new to ClojureScript, so maybe I just do something wrong here.

jrheard06:10:19

@teng i don’t think you need to manually rlwrap figwheel, lein figwheel should do just fine

jrheard06:10:25

what does your project.clj look like?

jrheard06:10:31

oh, hm, the readme does recommend rlwrap, my mistake

jrheard06:10:52

anyway usually there’s more output after the “successfully compiled” line, yeah

jrheard07:10:49

@teng you have :figwheel {:repl false} in there

jrheard07:10:53

take that out 🙂

tengstrand07:10:52

@jrheard now it works, thanks!

jrheard07:10:04

excellent, np!

lsenta07:10:18

Hi guys, I’m trying to TDD my clojurescript SPA

lsenta07:10:19

lein doo works but it’s not practical, my tests won’t run with phantomjs (firebase + websockets) and chrome does a terrible logging job. In the end, I have almost 0 feedback when I run my tests it’s not pratical

jrheard07:10:34

have you looked into devcards?

lsenta07:10:45

Haha I was getting there

lsenta07:10:18

What I’m trying to do: I have my SPA and I want to run it with figwheel to test the app

lsenta07:10:31

and run a second instance of figwheel for devcards

lsenta07:10:59

I hoped to do something like lein figwheel : spa is available at localhost:3449

lsenta07:10:23

and lein figwheel devcards: devcards / tests are available at localhost:3446 or whatever

lsenta07:10:53

But figwheel won’t let me set a port in the devcard build id, I don’t know where to go from here

lsenta07:10:34

So: how do you guys usually TDD / use devcards with your clojurescript app? And is there a way to get what I want without too much hacking around

jrheard07:10:09

(i haven’t actually used devcards myself and am heading to bed, but i’m sure someone else in the channel will be able to help you, good luck!)

lsenta07:10:02

Thanks for confirming devcards are a possible solution @jrheard 🙂 Have a nice evening

lsenta07:10:52

I’ll wait for the devcards users 😄

markwoodhall07:10:11

@mx2000 did you manage to sort your vim-fireplace problem out? There is some recent discussion around this in #vim-fireplace

urbanslug09:10:13

Can I write js (raw js) in my cljs?

lks12809:10:16

@urbanslug I believe you could do something like this: cljs.user=> (js/eval "function a(x){return x*2}; a(23)") 46

urbanslug09:10:38

Thanks lks128

darwin10:10:13

@teng from your snippet it is not really obvious what went wrong, is nomappsel.events the namespace where you defined your macro?

darwin10:10:16

then share both files, with full ns-forms, the problem is probably in the way how you require the macro

darwin11:10:29

they cannot be written in the same file as in Clojure

darwin11:10:35

unfortunately cljs compiler does not provide meaningful errors here, it treats the macro as a function with two “hidden” paramaters, that is why you got that error message

tengstrand11:10:40

@darwin Ok, thank you so much. It’s sometimes hard to know where to start 😉

darwin11:10:16

@teng patience 🙂 one day, it will all “click” and make sense

tengstrand11:10:04

@darwn It’s really awesome, a lot better than OO and we are already as productive as in Java (after only two months) and we produce about 90% less code and complexity than before! 😉

tengstrand11:10:08

@darwin now it works! thx

darwin11:10:44

@teng look at the generated js code, you probably want to extract the :api-url key during compilation on macro side, or capture whole (emit-api-uri) in a clojurescript variable and then use it during runtime

darwin11:10:32

I would do the later

darwin11:10:12

(def config (emit-config)) (def api-uri (:api-uri config))

bhauman11:10:49

@lsenta: the solution is to run both in the same process: lein figwheel spa devcards

codxse11:10:00

Sorry guys to intrupt. What is clojure/clojurescript database that work natively like php to mysql or javascript to mongodb??? I heard about datomic, but Im not sure.

crankyadmin11:10:41

Would work for Clojure.

crankyadmin11:10:20

Really depends what you mean by ‘natively’

codxse11:10:09

I mean native like doesnt need to include other library to support it.

codxse11:10:40

But sure thanks for your answer :)

crankyadmin11:10:26

Well both PHP and Javascript both require additional libs to connect to databases… 😐

crankyadmin11:10:40

Of course there is PDO as well.

crankyadmin11:10:58

But either way the point still remains…

dimovich12:10:02

hello clojurians

dimovich12:10:10

what is your choice of grid framework?

dimovich12:10:18

so many options out there

nfisher12:10:33

@dimovich I’ve often skipped the “big frameworks” in favour of smaller ones that just deliver what I want. I’ve often used Skeleton but it’s not flexbox based.

lwhorton14:10:43

Heya guys, i’m a little confused on how I would extend-type clojure.lang.IPersistentMap to add a protocol. Is the IPersistentMap the right way to go about it?

lwhorton14:10:18

I want to add a protocol to a map so that I can invoke some function with either a map or a string and do a protocol dispatch appropriately, but I get errors trying to either :require clojure.lang or inline a fully qualified clojure.lang.IPersistentMap

dominicm14:10:13

For cljs, you want cljs.core.PersistentArrayMap

dominicm14:10:23

There's probably an I prefixed version of that too.

lwhorton14:10:02

hmm thanks @dominicm . I don’t see one of those but I’ll keep scrubbing the source looking for one. I’m hesistent to use persistent{impl}map because in clojure i know hash vs array map depends entirely on size, so you have to extend the I or you’re missing cases

meatballs14:10:29

don't try to extend the I version in cljs. protocols can't extend protocols.

dominicm14:10:14

@meatballs cljs.core.IPersistentArrayMap being different to clojure.lang.IPersistentMap would confuse me?

meatballs14:10:36

lwhorton: it looked like you were in vanilla clojure, not cljs originally. here's an example of what could work for you: https://gist.github.com/anonymous/3279a96dc760a63716ba1527ef88065e

meatballs14:10:02

alternatively, you can extend-protocol and do them both in one call.

dominicm14:10:22

@meatballs I think @lwhorton wants this to work in clojurescript

lwhorton14:10:44

yea sorry for the lack of clarity, I want it to work in cljs. I’m just not so sure the type sharing differences between clj and cljs.

lwhorton14:10:28

the really weird thing is that for a few hours yesterday clojure.lang.IPersistentMap was working in in cljs. only after I restarted my build process fresh today does it complain about Cannot read property 'IPersistentMap' of undefined

meatballs14:10:38

oh, ok. well, that is strange. they live in cljs.core in cljs, not clojure.lang

meatballs14:10:33

well, yes, you will have to target the different sorts of maps individually, not by their interface-esque protocol since protocols can't extend protocols. you can try it yourself for proof, but see the following for an example of extending all of the concrete types: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L9380

meatballs14:10:09

PersistentArrayMap, PersistentHashMap, and PersistentTreeMap

dominicm14:10:06

@meatballs In Clojure you can target something like IPersistentMap (which is not a protocol in Clojure). I think the distinction might be that clojurescript doesn't have a concept of a hierarchy.

dominicm14:10:32

Check the result of (ancestors (type {})) in both cljs and clojure

lwhorton14:10:18

another piece of confusion for me is exactly that: https://www.paren.com/posts/isomorphic-clojure-part-2-portable-code … here they mention that clojurescript can only extend concrete types because it lacks interfaces, and protocols cannot be extended to other protocols.

lwhorton14:10:31

so instead of extend-type type we’re doing extend-protocol type?

lwhorton14:10:48

is there a difference between

(extend-protocol Pro
  PersistentArrayMap (pro [this] …)
  PersistentHashMap (pro [this] …))
and
(extend-type PersistentArrayMap
  Pro
  (pro [this] …))
(extend-type PersistentHashMap
  Pro
  (pro [this] …))

lwhorton14:10:03

ill keep reading, thanks @meatballs and @dominicm . for now extend-type on both arraymap and hashmap will do.

meatballs14:10:59

lwhorton: no different. extend-protocol calls turn into extend-type calls. use whichever suits your situation better.

mathpunk23:10:42

I want to build a frontend application to visualize some data. Since I'm trying to do it in small pieces, I figured I'd start by shoving this json data file I have in, and learn to write a server later. But, I'm not sure how to get a file into a context where my frontend code can see it.

mathpunk23:10:18

First I tried using the fs module before remembering, it's not Node. I remembered to not try slurp, 'cause I did remember it's not on the JVM. Next I tried just copy-and-pasting that data as a string in but it's full of quote marks

jrheard23:10:49

if you just want to have a string of escaped json data that you can paste into a cljs file as a string literal, that should do the trick (never used it, just found via random googling)

mathpunk23:10:18

that is what i figure i want for now --- i'm trying to solve problems in the order that they matter and right now i just want to build something that visualizes

jrheard23:10:26

++ sounds wise

mathpunk23:10:29

i mean, i'll take suggestions on "the right way" as well but

jrheard23:10:21

the “right way” would probably be to have your cljs make an ajax GET request to a /foo/bar server-side endpoint, or to a static file like /resources/data.json, but don’t quote me, i’ve never actually written any cljs that makes ajax requests

mathpunk23:10:02

@ag: not quite -- it's not the parsing that's the trouble, it's getting the data into the browser context, while avoiding frustrating myself by trying to figure out http/ajax solutions first

mathpunk23:10:20

that json-escaper is going to do the trick i think

ag23:10:54

does it have to be json? can you use edn? then maybe just stick it to js/window with clj->js?

mathpunk23:10:39

@ag: JSON is what came out of the service I'm querying. But, I'm intrigued -- js/window is sort of the global context for the browser, then?

jrheard23:10:08

yeah, if you have some javascript that runs before your cljs and sets window.foo = 3, your cljs should be able to see js/window.foo

mathpunk23:10:00

I will make a note of it, though the problem at hand seems to be solved kludgily enough for now

ag23:10:25

Duct tape is magic and should be worshipped.