This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-13
Channels
- # beginners (14)
- # boot (108)
- # carry (6)
- # cider (28)
- # cljs-dev (107)
- # cljsrn (32)
- # clojars (4)
- # clojure (62)
- # clojure-austin (15)
- # clojure-berlin (1)
- # clojure-brasil (3)
- # clojure-chicago (1)
- # clojure-dev (9)
- # clojure-greece (2)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-poland (2)
- # clojure-portugal (1)
- # clojure-russia (24)
- # clojure-spec (63)
- # clojure-uk (30)
- # clojurescript (123)
- # cursive (13)
- # data-science (1)
- # datascript (1)
- # datomic (27)
- # devcards (11)
- # dirac (1)
- # emacs (5)
- # events (4)
- # hoplon (27)
- # jobs (3)
- # juxt (3)
- # leiningen (11)
- # off-topic (18)
- # om (46)
- # om-next (7)
- # onyx (50)
- # pedestal (6)
- # portland-or (8)
- # proton (16)
- # re-frame (38)
- # reagent (21)
- # ring-swagger (14)
- # specter (46)
- # untangled (116)
- # vim (46)
- # yada (22)
well, your configuration is probably wrong, I assume you wanted to use browser+figwheel, not headless rhino javascript interpreter
you should follow this: https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl if you want cljs repl from figwheel
I’m afraid you or someone you called, used (cljs.repl.rhino/repl-env)
as your REPL environment
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
I’m sorry, this stuff is pretty complicated and you should build a mental model to be able to troubleshoot problems
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
the problem is probably in the point where cljs repl is being created via piggieback, the repl-env is probably wrongly configured
@dnolen: Thanks for the help 🙂
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.
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
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...
@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)
Got it to work -- Emacs/Cider to figwheel to android (and from Windows dev box) -- thanks to #Doglooksgood
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.
@teng i don’t think you need to manually rlwrap figwheel, lein figwheel
should do just fine
@jrheard Good idea! 😉
@jrheard now it works, thanks!
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
I did, https://8thlight.com/blog/eric-smith/2016/10/05/a-testable-clojurescript-setup.html
What I’m trying to do: I have my SPA and I want to run it with figwheel to test the app
and lein figwheel devcards
: devcards / tests are available at localhost:3446 or whatever
But figwheel won’t let me set a port in the devcard
build id, I don’t know where to go from here
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
(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!)
@mx2000 did you manage to sort your vim-fireplace problem out? There is some recent discussion around this in #vim-fireplace
@urbanslug I believe you could do something like this:
cljs.user=> (js/eval "function a(x){return x*2}; a(23)")
46
@teng from your snippet it is not really obvious what went wrong, is nomappsel.events
the namespace where you defined your macro?
then share both files, with full ns-forms, the problem is probably in the way how you require the macro
@teng: learn about macros: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#macros
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
@darwin Ok, thank you so much. It’s sometimes hard to know where to start 😉
@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! 😉
@darwin now it works! thx
@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
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.
Would work for Clojure.
Really depends what you mean by ‘natively’
Well both PHP
and Javascript
both require additional libs to connect to databases… 😐
Of course there is PDO as well.
But either way the point still remains…
@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.
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?
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
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
@meatballs cljs.core.IPersistentArrayMap being different to clojure.lang.IPersistentMap would confuse me?
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
@meatballs I think @lwhorton wants this to work in clojurescript
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.
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
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
@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.
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.
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] …))
ill keep reading, thanks @meatballs and @dominicm . for now extend-type on both arraymap and hashmap will do.
lwhorton: no different. extend-protocol
calls turn into extend-type
calls. use whichever suits your situation better.
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.
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
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)
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
@mathpunk is that maybe what you need? https://github.com/dakrone/cheshire
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
@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
does it have to be json? can you use edn? then maybe just stick it to js/window with clj->js
?
@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?
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