This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-25
Channels
- # bangalore-clj (2)
- # beginners (50)
- # boot (21)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (93)
- # clojure-russia (5)
- # clojure-spec (22)
- # clojure-uk (3)
- # clojurescript (24)
- # data-science (4)
- # datomic (1)
- # events (2)
- # fulcro (46)
- # graphql (9)
- # hoplon (16)
- # lumo (42)
- # off-topic (3)
- # perun (2)
- # protorepl (1)
- # re-frame (10)
- # reagent (12)
- # ring (1)
- # ring-swagger (1)
- # shadow-cljs (12)
- # specter (16)
- # unrepl (10)
I need to do a visualization of a chess board, placing points within various squares and lines connecting those points. I thought I might use a plotting library for this as it's sorta similar to a line plot, does anyone have any recommendations for a simple library I might use?
don't know if it helps, but this is probably the simplest as you can get for easy charting https://github.com/yfractal/chartkick
if i wanna spin up a tiny dumb node/cljs command-line app, what's the least painful way to get started?
you can install lumo (a self hosted cljs on node) with npm
lein is a java app
I'm just saying, i wouldn't expect it to be especially useful for something that's 100% node
i've used it for clojure stuff before, but haven't done much clojurescript and certainly haven't done any cljs in quite some time
Hi all, I'm trying to write a simple re-frame app. So, I have code like this:
(defn note-summaries
[]
(let [items
(into [] (map #(identity [:li [:p %]])
@(re-frame/subscribe [:notes])))]
[:div
(if (pos? (count items)
items
[:p "No notes!"]))]))
Now, I get error in browser console like this:
Uncaught Error: Assert failed: Invalid Hiccup form: [nil]
(valid-tag? tag)
at reagent$impl$template$vec_to_elem (template.cljs?rel=1511540933817:302)
at reagent$impl$template$as_element (template.cljs?rel=1511540933817:329)
at f (dom.cljs?rel=1511540933878:53)
at reagent$dom$render_comp (dom.cljs?rel=1511540933878:30)
at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$3 (dom.cljs?rel=1511540933878:54)
at reagent$dom$render (dom.cljs?rel=1511540933878:41)
at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$2 (dom.cljs?rel=1511540933878:49)
at reagent$dom$render (dom.cljs?rel=1511540933878:41)
at Function.reagent.core.render.cljs$core$IFn$_invoke$arity$2 (core.cljs?rel=1511540934258:75)
at reagent$core$render (core.cljs?rel=1511540934258:66)
at ekathuwa$core$mount_root (core.cljs?rel=1511578336868:20)
at Object.ekathuwa$core$init [as init] (core.cljs?rel=1511578336868:26)
I want to know how to go debugging something like this. I'm quite new to this of course, so I don't really need an answer for this specific bug, but advice on what tools/techniques to use to go about figuring out such a bug. Thanks!@duminda somehow [nil]
got passed as a reagent component - that's not valid and can't be rendered
but I don't see how the code you showed would create that
@noisesmith: Figured it out. (if (pos? (count items)
line is missing a closing paren. Funny how often I figure out problems immediately after I ask someone else online (Even without help) :thinking_face:
But, are there any standard debugging/helper tools I'm supposed to use?
@duminda aha! that if is broken
you pass too many args to pos?, so the if returns nil
@duminda no, my experience is that bugs with data passed to react lead to verbose and completely unhelpful error messages
because of the way react sets up rendering, it doesn't have a way to provide info about where the data it is rendering from came from in your code
or that's what I am led to believe
@noisesmith: Yeah, I had quite a few during yesterday. But they are totally useless - I agree.
one thing that can help a lot is unit testing your components with representative data - at least then you know precisely which thing was being tested when the failure happened
you can make a test that mounts just that component to the dom, then makes assertions about the results
see also dev-cards, from the guy who made figwheel
similarly, it leads you to develop things one working part at a time, which makes it clear where the errors are
Got it, I tried out spec, I was under the impression that it can sort of auto-generate tests... Anyway, I didn't want to write tests right now because I'm just feeling out how this works. But guess I have no choice now
As always, thanks for your help @noisesmith
you can totally get by without writing tests - but they help, and dev-cards can actually speed up your dev process
because instead of building a whole component then rendering your page, you can try out the smaller parts one by one
so i've gotten started with lumo and i really like it, but i want to pull in specter (https://github.com/nathanmarz/specterhttps://github.com/nathanmarz/specter) and i'm not entirely sure how (best) to do that in the absence of a lein project.clj
is there a core function that describes applying a series of clauses where the clause is a [pred f] and f is applied only if the pred passes? e.g
(??? {:age 5 :name "sally"}
:age (fn [x] (update-in x [:age] inc)
:name (fn [x] (update-in x [:name] (str "silly-" %)))
=> {:age 6 :name "silly-sally"}
cond-> is kind of like that
It’s good for this kind of data structure manipulation
It threads so you would omit the x on the rhs
(cond-> m :age (update :age inc) :name (update :name #(str “silly-“ %)))
Matches don’t stop the threading so the fns are applied for all matching preds
Yep, that looks like what i want. Thanks alex.
also, if you need to see consequences of the previous step in your conditional, you can chain multiple calls to cond-> inside ->, or use as->
Thanks @noisesmith. Thats what i was doing already for other reasons, but i didn't know that was necessary tell you said as much. minor note, the predict functions of the clauses in cond-> aren't sent the expression. So you need to pass it directly.
(cond-> m
(contains? m :age) (update :age inc)
:name (update :name #(str “silly-“ %)))
Otherwise the text expression is just the keyword and thats always trueYeah, sorry about that!
right, that too 😄
so often what I really want is (as-> m (cond-> (contains? m :foo) (update :foo inc)) (cond-> (contains? m :bar) (update :bar dec)))
or similar
I'm i correct that https://github.com/pallet/alembic should allow me to add jar to my project and not need to restart my repl? or i'm i mis-understanding it?
yes, it has a function that loads deps from an edited project.clj
@drewverlee it's all right here https://github.com/pallet/alembic#usage