This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-09
Channels
- # admin-announcements (43)
- # beginners (11)
- # boot (141)
- # cider (48)
- # clojure (82)
- # clojure-canada (1)
- # clojure-dev (1)
- # clojure-norway (20)
- # clojure-russia (6)
- # clojure-uk (12)
- # clojurescript (268)
- # datomic (14)
- # editors (5)
- # euroclojure (5)
- # jobs (2)
- # ldnclj (109)
- # off-topic (7)
- # om (6)
- # other-lisps (3)
- # re-frame (13)
- # reagent (3)
- # sim-testing (5)
- # sydney (1)
Effectiveness sans Formalism, killer shit http://www.cs.ubc.ca/~gregor/papers/kiczales-oopsla-07-for-viewing.pdf
Sadly now w/o images but also a big source of inspiration by Kiczales http://people.engr.ncsu.edu/efg/517/f00/syllabus/annotations/lec13.html
core.async gives zero hints as to where an error is happening (difficult when you have quite a few go blocks), will this ever improve?
@afhammad: you stack traces get lost? In newer versions of chrome this should work I think. There is something about that I'm the re-frame wiki
@afhammad: recent versions of Chrome are waaaaaaaay better at giving you a proper stacktrace from within a core.sync go loop.
So using Canary may be worth your time
@a.espolov: it’s async, hence no return value (in earlier version the results were returned)
@afhammad: background: Chrome 43 (and prior) does not give proper stack traces when an exception is rethrown ... it reports the stack trace for the rethrow point, rather than the original throw point ... and core.async go-loops catch exceptions and rethrow them. Result: useless stacktraces
Summary: use Chrome 44 (Canary?) for debugging anything involving core.sync. Chrome Stable is currently 43.
@a.espolov: the best way to get at the results is to extend the cljs.test/report
multimethod to create a custom reporter
here was a rough version where i took that approach: https://github.com/crisptrutski/boot-test-cljs/blob/7be037aeb435eb5cd31ea17a525ee732b17f25f0/src/pandeiro/reporter.cljs
@crisptrutski thx man)
@crisptrutski: I did so, but there is a but(
And there's always 0 returned and finally I have the step of testing in the CI all OK, and on the fact the console was hatched testing errors(
not familiar with vovzvraŝaetsâ - but good thing you had zero of those (sound scary)
maybe you want something like this in your reporter? (when (pos? (:fail m) (System/exit 1))
In breaking up my growing cljs app into functional modules (as opposed to concerns like handlers, views and subscriptions), I find myself having to :require
the same list of dependencies in each file. Is there a way to include a preset list of deps in each file? :use comes to mind, but it's considered "bad style".
clojurescript doesn’t have a wildcard :use, so not sure that’s relevant 😉
in clj some libraries (eg timbre) provide macros to load all the namespaces and refer particular things
but i don’t think cljs has a require statement (i could be wrong though.. i know cljs repls do, the boot one at least)
here’s @luke saying that there’s no require statement, but that might have changed http://stackoverflow.com/questions/12879027/cannot-use-in-clojurescript-repl
@crisptrutski in cljs (System/exit) ?)
good point. are you using lein or boot?
cljs-build should be taking care of exiting with the right code, guess i need to know more about the task your ci is running
Can I write a macro that expands into the (:require ...)
statement that I need?
@petrus (ns ..
) is a macro in cljs I believe, so it executes before the inner forms
perhaps you can use a macro to generate the ns
form itself.. not sure
chicken and egg actually - how do you load that macro without an ns form
maybe you can have repeated ns forms though?
out of my depth here
think there’s a reason implicit requires not in clojure though - think grinning and bearing the imports is more “simple”
depending on what the concerns actually are, should be able to have a small stable set of namespaces you boilerplate
Hmmk. I want to save myself having to import each function as I need it, because there is a set of common functions that each functional module eventually needs.
just alias the namespace rather than refering to functions
with :as ?
https://gist.github.com/dark4eg/453a77ecd9971a3af83e - html https://gist.github.com/dark4eg/bdf6a217117d6ec4ceb1 - polyfill.js https://gist.github.com/dark4eg/f6a69d2933b00794ccd5 - unit-test.js
@a.espolov: ok, so it’ll come down to how you’re loading that html
could throw an exception in the reporter and listen for exceptions in the html runner - that was the approach taken in the repo i linked you to
Hmk. Last thing on deps: can I have a "base" ns that pools in some common functions and exposes it through a hypothetical :export, e.g. (ns myapp.utils (:require [myapp.events] :export [handler-fn] ...)
so that anything that aliases myapp.utils :as utils
can refer to utils/handler-fn
?
...instead of each sub namespace having to :require myapp.events.
potemkin provides the classic macro for re-exporting vars in clojure (and people have often rolled their own thing)
there are people doing it with clojurescript too, but no canonical version i’ve seen, no tricks without their flaws afaik
saw discussion on re-frame around doing exactly that - suggest skimming their issues and seeing where things are at
http://side-effects-bang.blogspot.com.au/2015/06/importing-vars-in-clojurescript.html <-
@crisptrutski: thanks. That's cool.
@dnolen: is it ok if I use your core.async webinar examples for a talk about clojurescript?
@petrus @crisptrutski fwiw I don't think things like Potemkin are any good. It’s become idiomatic to just alias a ns and not even bother with :refer
most of the time.
also in the ClojureScript context I would avoid any Potemkin like thing until somebody proves it does not defeat dead code elimination.
@dnolen do you have examples of people already leveraging an om-next approach in the wild ? I'm most interested in seeing how they wrap around the persistence layer to expose a query route which handles auth, scoping & similar matters
my naive vision was that there might be room for a somewhat generic query endpoint which would support wrappers to do pre-flight checks on a request, but it might indeed end up being so generic that it wouldn't be very useful
one last question re: om-next. is an approach similar to what fb relay's seem to use for mutation (optimistic updates, and available mutations) likely to end up in components or do you expect this to be provided by 3rd parties as well
(referring to the points mentioned in: https://speakerdeck.com/laneyk/mutations-in-relay)
however, again we’ll supply a store that can do this if you couple it to the router I mentioned and you have Datomic as your DB
this will just work, but they will be simple components, again easy to study and supply your own thing
so we’re more like Falcor in this regard, no assumptions about what your stack is capable of
but we’ll ship a full working basic example of the machinery required to accomplish a full Relay thing.
Hello Clojurescript world.
leveraging pull just lets client get exactly the side information they might need - but sanitizing the keys, filtering the database - that’s the code you have to write.
@wildermuthn: hello!
Hi! A millions thanks for the work you’ve done on Clojurescript!
@dnolen: awesome. I'll tackle this to see if I end up with something satisfying enough, every excited by the direction om-next goes in, thanks again
@wildermuthn: thanks, but there’s a lot of people to thank these days, a 108 last time I checked 😉
Is there a cljs repl that supports tab completion?
@wildermuthn: nothing out of the box at the command line that I’m aware of, I think only Cursive and Cider reliably support that.
ok thx. I use vim, so that’s probably my first problem.
Fireplace is great, but without knowing vimscript, kind of limiting.
@wildermuthn: think fireplace can't offer completion in the places where you enter commands (the pseudo-repl), due to vim limitations 😞
@tcrayford: that’s been my experience, so I use figwheel’s repl most of the time unless I’m doing inline evaluation of a form. More often than not, I’ll use a #_ (…) and evaluate from vim rather than switch to the repl.
So when I have a bug inside a go loop, the dev tools call stack doesn’t always give me information I understand:
https://www.dropbox.com/s/4atvpoz8v07wkck/Screenshot%202015-07-09%2008.46.51.png?dl=0
The exception helps, in that it tells me I’m conjoining with a bool, but is there data somewhere inside the call stack that would help me identify where?
Fairly often, printing out the exception to the log will give me a line number. But sometimes not.
Hmm, same with Canary. I think I figured out what’s happening. The go loop is inside a macro. When I create the same bug manually, without a macro, I get the right call stack.
@wildermuthn: if you don’t have a line number is seems like the actual bug has not been solved
Right. I mean that I narrowed down when the bug occurs for me. I’m looking through the issues on dev.clojure for mention of something like this.
but even so do not open a ticket about stuff like this unless you’ve absolutely determined it isn’t a Chrome issue
Sure thing.
Safari and Firefox also source support source mapping so you’ll need to verify similar results there
it maybe a manifestation of a core.async issue Clojure had which was remedied by switching to tools.analyzer and the fact that this stuff hasn’t yet been ported to ClojureScript.
Issue doesn’t appear in Safari. https://www.dropbox.com/s/4aulw6de5yeq9r1/Screenshot%202015-07-09%2009.18.25.png?dl=0
vs Chrome's
That’s Canary, actually. Might have to keep Safari open! Interesting.
Like you said, it wasn’t the go loop or macro, but core.async
tangential - giving every single function a name was probably the best enhancement to source mapping in a long time - sort of slipped in for other reasons, but it really helps when debugging.
errr, plus Chrome.
@dnolen, Firefox works fine as well. Yeah, the names are really helpful. One more reason to switch from JS. https://www.dropbox.com/s/k77tw0varqlll64/Screenshot%202015-07-09%2009.35.08.png?dl=0
A beginners question. I like to instantiate a javascript libary in clojurescript.
clojurescript
(def xhr net/xhr-connection)
But the compiled javascript looks like
javascript
webvr_menu_creator.core.xhr = clojure.browser.net.xhr_connection;
So no class is created. What did I do wrong?Shouldn't look like
webvr_menu_creator.core.xhr = new clojure.browser.net.xhr_connection;
Its referenced from http://clojure.browser.net the method is
(defn xhr-connection
"Returns an XhrIo connection"
[]
(XhrIo.))
Thank you.
How can I define, which google closure library is used? Somehow there are different version in the IDE and in the browser.
Okay nevermind, found the error. I call send with
(.send xhr url callback)
which then calls
goog.net.XhrIo.prototype.send
But i want to call
goog.net.XhrIo.send
How can I do this?@danielgrosse: there is no such thing
so you want to call the static method, not the instance method?
@mcgivernsa: there is no static method
@danielgrosse: if you want to do that skip
yeah, I was talking about this which the docs call a static ... function, I guess https://closure-library.googlecode.com/git-history/docs/local_closure_goog_net_xhrio.js.source.html#line302
@dnolen: thank you again, that is the solution.
@danielgrosse: yeah sorry I didn’t realize that goog.net.XhrIo.send
existed, should have checked first.
What would be the core.async equivalent to Promise.all
? [(<! (go ...)) (<! (go ...))]
?
The results wouldn't be in the same order that they are declared and there's no obvious way to know which value came from which channel.
Use case: I want to do two asynchronous "subtasks" in parallel and coordinate on the result.
I'm attempting to round-trip a map (ClojureScript-Clojure, client-server) in EDN format, with cljs-ajax and Carmine. Since that wasn't working, I'm just trying with cljs-ajax and clojure.edn. (Previously, I couldn't do it with JSON either). Is there something obvious I'm missing?
I removed all my Ring middleware, just to be sure.
@coyotespike: fogus did some Ring edn middleware that I’ve used before, worked for me.
however these days I would just use Transit, cljs-http and some transit middleware worked for me
@dnolen - thanks! I'm now trying cljs-http with :transit-params, and ring-transit with wrap-transit-body. It's sort of starting to work.
@escherize: but of course!
It's not ready yet but i just made some progress and am really excited about it! http://take.ms/SDjBe intractive graphs in cljs
@escherize: Cooooooool!
I'm using http://marvl.infotech.monash.edu/webcola/ so I can't take a lot of credit 😄
@dnolen: Halfway through watching Om Next, and decided to change my side project from reagent to Om Next. Thanks!
@escherize: neat!
Earlier David kindly pointed me toward how to send a map - and success! With cljs-http, I can POST and then GET a map. Now I'm trying to pass some parameters with a GET request, using cljs-http, and then use those parameters on the Clojure side.
(http/get "/redis-get" {:query-params {:key1 "value1"}}
passes the map along with it, which is good.
And then on the server side, using wrap-keyword-params, I can use :query-string to get out the map - but it's just a string, not a Clojure data structure.
Never mind, got it! (wrap-keyword-params (wrap-params handler))
, and then (keyword-params-request request)
, did the trick. Fireworks, applause. Sorry for the noob question.
So, I'm trying to start a repl as per https://github.com/clojure/clojurescript/wiki/Running-REPLs , and I'm getting Exception in thread "main" java.io.FileNotFoundException: Could not locate cljsbuild/compiler__init.class or cljsbuild/compiler.clj on classpath.
. I'm wondering if I've maybe run into this issue? https://github.com/emezeske/lein-cljsbuild/issues/204
Now realizing that this particular project is still on 1.7.0-beta3
. Is that the culprit?
dnolen: but I think its on the down low as to the department, the guy was a bit evasive
When people are running their tests in the REPL via https://github.com/clojure/clojurescript/wiki/Testing#running-tests are they restarting a new lein
process every time? There's no tools.namespace
analogue, right?
Ah. I'm also seeing the :watch
option on the REPL function: https://github.com/clojure/clojurescript/wiki/REPL-Options
Though now I'm having trouble including my files in the classpath. I guess the REPL script isn't what I want, and I should just lein repl
and launch the appropriate REPL function from there?
Newbie question: Should I use leiningen for a cljs node.js project? It seems to look like it's not a favorite approach here: https://github.com/clojure/clojurescript/wiki/Quick-Start
@mikethompson, @martinklepsch: thanks, installed Canary and now getting stack traces.
@bhagany: I didn't, because I already had a good figwheel-based workflow before I started grappling with unit testing.
@zane: seperate build in a separate tab on your browser and the launch fighweel with lein fighweel dev test
@zane: you can have a runner that has :^fighweel-always on it and (run-tests)
at the bottom
Also if it works for you I would really love it if someone could write a wiki for that and
@zane: I would be remiss, if I didn't mention that the new new devcards has pretty sweet integration with cljs.test but it's a very easy path to integrate an existing cljs.test suite so I would keep heading the way you are now
@dnolen: I get it. Just need to wrap my head around why (.. this -props -my_prop) wasn't working in advanced mode
@dnolen: so to be clear. it seems that this code (.. #js {:some #js {:thing 5}} -some -thing)
worked in :none and :simple but not :advanced