This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-02
Channels
- # admin-announcements (11)
- # beginners (183)
- # boot (139)
- # cider (37)
- # clojure (134)
- # clojure-germany (23)
- # clojure-italy (28)
- # clojure-japan (24)
- # clojure-russia (12)
- # clojurebridge (17)
- # clojurescript (222)
- # code-reviews (6)
- # core-async (9)
- # core-matrix (4)
- # datomic (13)
- # editors (2)
- # euroclojure (13)
- # ldnclj (69)
- # off-topic (32)
- # om (3)
- # onyx (24)
- # reagent (10)
- # yada (31)
oops.. now I did ctrl-c
in REPL and now even rlwrap java -cp cljs.jar:src clojure.main repl.clj
doesn’t work
Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/browser/repl__init.class or clojure/browser/repl.clj on classpath., compiling:(/Users/Chico/Projects/om-test/repl.clj:1:1)
chicoxyzzy: double check that your cljs.jar is an ~18mb file, common mistake to download the wrong thing
@chicoxyzzy: otherwise make sure you don’t have a global classpath setup with some version of Clojure on it
I didn’t change it anyhow when completing previous steps of tutorial and it looks fine
19842263 Jul 1 22:28 cljs.jar
@chicoxyzzy: seems very weird, but the error says different
yeah, one of the main features of clojure/clojurescript that has kept me happy is the community. There is a lot of mutual respect between library authors and no feuding, compared to other communities.
@chicoxyzzy: you will only get that error if the classpath is wrong, or somehow the wrong version of Clojure is getting loaded
@chicoxyzzy: and reading back - namespaces map to Java packages more or less and those must match the classpath
ok thank you. I’ll try to fix my issue and change my namespace to om-test.core
CLJS compiler question: When it analyzes an ns
declaration, does it begin emitting JS immediately or does that occur after the entire file has been analyzed?
cool. just created new project from scratch and all works fine now. than you @dnolen
https://github.com/clojure/clojurescript/wiki/Rationale#javascript-engines-gain-power I think we should add some info about forthcoming Web Assembly there
@domkm: See very end of this post as a guess at an answer: http://blog.fikesfarm.com/posts/2015-06-15-see-js-in-cljs-repl.html
@mfikes: I’d like to write a macro that can be used from cljs to alter the current namespace. It seems like that might not be possible or might be too prone to breakage by compiler changes.
@domkm: ns
is just a special form. It can be used in the middle of a file, if that's what you are thinking.
@mfikes: I’d like to be able to alter a cljs namespace in a similar way to how potemkin can import-vars. I think I have it mostly worked out except for namespace alternation because cljs doesn’t have require
.
@domkm: If you write a macro that involves ns
, I suppose you'd have to be sure it comes back into ClojureScript after expansion.
@domkm are you looking just to import vars like potemkin? Or something more?
@danielcompton: Yes, import vars
http://side-effects-bang.blogspot.com.au/2015/06/importing-vars-in-clojurescript.html
Thanks. Unfortunately that just defines new vars which means that they have the wrong metadata. It also doesn’t work for macros.
Ah rats, I hadn’t tried it yet
@domkm: (doc ns)
will work in the next release. A preview of the output (showing it is a special form) is in http://dev.clojure.org/jira/browse/CLJS-1307
question on using cljs-ajax if someone has time ..
i have a liberator delivering a json api (above) and I am trying to make a ajax get call to load it into an atom (for looking at in figwheel repl) and printing to log …
i I load the page in the browser.. in figwheel repl I run (get-data) and this is the output
Figwheel: trying to open cljs reload socket
utils.cljs:40 Figwheel: socket connection established
ioc_helpers.cljs:41 Uncaught Error: No protocol method ReadPort.take! defined for type null:
xhrio.js:561 XHR finished loading: GET "”.
i see in the network requests it accesses the url and response is data
i am using emacs
i look at the network tab and see my json data is Content-Type:text/plain;charset=UTF-8 .. maybe that has something to do with it ..
@clojuregeek: looks like something to do with core.async
ioc_helpers.cljs is a core.async file
i’m not using core.async for loading the data
cljs-ajax is though
do you know where exactly the error is thrown? Inside get-data, or inside handle-response?
let try again, i had typo in my handle function.. i’ve been trying different versions
hm got something back..
ok i think i’m getting back a string I need to parse to json.
@clojuregeek: cljs-ajax has some helpers to do this for you
oh so dont need cheshire ?
@clojuregeek: shouldn’t need to, https://github.com/JulianBirch/cljs-ajax#json-specific-settings
ah that works
ok thanks so much.. i better get to bed now before i get in trouble with hubby
Last night I converted bidi from cljx to cljc, following the 1.7 announcement. However, I'm struggling to persuade lein to pick up the .cljc files in testing - is there an approach to testing that people are using that is working for them? Could really use some help here
@malcolmsparks: I think there's some open issues around that, though if you pass particular files/namespaces (can't remember which) they'll be tested
To lein test that is
When I deploy to heroku with :optimizations advanced, it fails with cannot call .. on undefined,
it fails at this line https://github.com/slipset/moon/blob/master/src/cljs/moon/components.cljs#L134
@slipset sounds like you're using a library with a bug. You need to find the source that makes that invocation.
From looking at the code, it seems as if it is the js reader thingy which is causing me problems, since I'm passing js-opts to an om-component,
The value of the key :now will be a float, which I guess has to be stringified so it can be passed to javascript.
I'm pushing a commit with :optimization :advanced right now, so I can give more exact info
in om, when you have a component you pass a first argument which becomes the attributes of the html-element, right?
You said the error shows a call to format. You need find what code calls format. Nothing else is relevant really.
Using dependencies from http://cljsjs.github.io/ … Is there anything else you have to do after adding the dependency to project.clj and :require
'ing the namespace in a .cljs file?
@stuartsierra: nope, that should be all
perhaps an issue with the packaging on the cljsjs artifact? externs issue?
@martinklepsch: looks like your boilerplate metadata is showing 😉
Specifically, loading cljsjs.d3 causes "Uncaught SyntaxError: Unexpected token ILLEGAL" in the JavaScript Console. I know this is an issue with D3 in general — the JavaScript sources use UTF-8 characters.
The recommended solution is to make sure d3.js is sent to the browser with UTF-8 encoding.
Figwheel is sending the JavaScript to the browser.
stuartsierra: Just a stab in the dark, Are you using the <meta charset="UTF-8"> tag in your header?
@bhauman: No. Also not my HTML.
@bhauman: Looks like that might have fixed it. Thanks!
At this point I think that should be on every default template. Adding it to the figwheel template now.
My standard index.html file, fwiw:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="app"></div>
<script src="app.js"></script>
</body>
</html>
Is <meta charset="utf-8">
a real thing?
I thought it was <meta http-equiv="Content-type" content="text/html; charset=UTF-8">
I guess I do old-fashioned HTML.
@stuartsierra: yep 😉
the html I posted is the minimal amount to be compliant with good "responsive html" practices
I still don't use any of the new html5 "semantic" tags, it just never occurs to me to use them.
(html
[:body
[:header {:role "banner"}
[:nav {:role "navigation"}]
]
[:aside {:role "complementary"}
]
[:main
]
[:footer {:role "contentinfo"}
]
]))
my advanced compilation ClojureScript app.js file is quite large. How can I reduce the size? Is it core.async that's eating that much space?
@dnolen: 0.1.56 just landed with a bunch of CLJC fixes. Still more to do but is hopefully more usable now. If you’re still having problems I’d like to know about them.
Hi. Is lein new mies still the recommended template? I saw no mention of it in the quickstart.
@shriphani: I’m actually thinking about deprecating them, don’t have any time to maintain them anymore
if I stick a transit-encoded map in a goog.net.XhrIo, it appears the xhr escapes my transit string again. Is there a way to avoid that?
@arohner: really? cljs-ajax and cljs-http must have sorted that out, I would look there.
yeah, I’m not seeing anything special yet. It seems like they just do the expected (t/write (t/writer :json) x)
in cljs-http callbacks, put results on channels. Elsewhere, take data from channels, and update UI
@dnolen: my double escape thing, which I know sounds super weird and sketchy 1) happens on some websites and not others 2) doesn’t appear to happen when using (t/writer :json-verbose)
@arohner: you’re the first person to report this issue so I don’t think it’s an actual problem
@samueldev: I think js->clj may work for you
thank you @johnmendonca
should I ask what essentially amount to "beginner Om/CLJS questions" here, or in #C03S1L9DN, or in #C053AK3F9
@samueldev: whatever gets the job done 😉
and its response objects are huge and seem to have the data nested inside somewhere
(def app-state
(GET ""
{:handler (fn [response] (.log js.console response))
:response-format :json
:keywords? true}))
response logs out to this object: http://puu.sh/iLbcC/15819d9c9c.png
@samueldev: you don’t want to debug that, you should print it to a ClojureScript thing
im trying to get the contents of response.tail.arr[0] in the form of a collection of clojure maps
this is my biggest issue right now i think, figuring out the "clojurescript" way to debug this stuff
😛 every piece of your advice leads me to more questions... gonna use my googlefu before asking lol
@samueldev: Are you using Figwheel yet?
Okay, good, good. The latest Figwheel allows you to set breakpoints as @dnolen just described. At the same time, you should through the Figwheel REPL be able to query def
s and so forth.
(def app-state
(GET ""
{:handler (fn [response]
(.log js/console (type response))
(js* "debugger;"))
:response-format :json
:keywords? true}))
first thing after params in a cljs fn is a return, so that debugger would never get hit
given that that's the case, should I not be able to iterate over it and build some om
components with om/build-all
? all of my questions derive from the first issue I ran into:
getting the following when I run om/build-all
...: Uncaught Error: [object Object] is not ISeqable
(defonce app-state
(GET ""
{:handler (fn [response]
(js* "debugger;")
response)
:response-format :json
:keywords? true}))
(defn project-view [project owner]
(reify
om/IRender
(render [this]
(dom/li nil (str (:name project) ", ")
(dom/a #js {:href (:github-url project)} (:github-url project))))))
(defn projects-view [data owner]
(reify
om/IRender
(render [this]
(dom/div nil
(dom/h2 nil "Project list")
(apply dom/ul nil
(om/build-all project-view (seq data)))))))
(om/root projects-view app-state {:target (. js/document (getElementById "app"))})
in other words om/build-all can't iterate over the PersistentVector? is my understanding?
samueldev: your app-state
is borked. GET
is async it’s not going to return anything meaningful right away.
if I throw my entire om component definition and rendering code into the callback of the cljs-ajax call