Fork me on GitHub
#clojurescript
<
2017-01-12
>
dnolen04:01:55

@timsgardner I’m not aware of any specific way to deal with that, might want to bring that up in #clojure-spec since it’s not specific to ClojureScript really

dnolen04:01:33

@timsgardner also might want to mention it to bhauman when he’s around, there should be a knob for that no?

joshjones05:01:25

is secretary still the most popular client-side router? i see it hasn't been updated in 2 years. bidi seems more frequently updated but i don't really need bi-directional routing. any other suggestions?

qqq05:01:00

I'm using bidi; I'm a big fan of it.

qqq05:01:25

I never used secretary; read the advertisement amterial on bidi, and was sold.

hlolli09:01:44

pretty-formatting code in cljs, specifically xml. Bit disappointed not to see data.xml/indent-str implemented in clojurescript. Any good maybe js libs that does this job well?

hlolli10:01:36

wondering if this is an expected behaviour of js-beautify?

cljs.user> (js/js_beautify "<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>")
"< note > < to > Tove < /to><from>Jani</from > < heading > Reminder < /heading><body>Don't forget me this weekend!</body > < /note>"
someone here that has experience with this library

ejelome10:01:54

those are html, I don't think js beutifier is the right tool for it

hlolli10:01:06

ok, Im led to believe this website is using that library for its demo http://jsbeautifier.org/ very beautiful output I get from xml. At js-beautify they claim to beautify css and html as well.

ujjwalt12:01:49

Anyone here has experience building Node.js projects with Boot?

danielstockton15:01:18

Has anyone written some methods to convert edn->query string params and back again, so they look pretty and you don't lose any data, that they wouldn't mind sharing?

dominicm15:01:13

I think there's something in goog.Url

danielstockton15:01:45

i doubt that works with edn, presumably i'd still have to write some code to convert into json

danielstockton15:01:57

problem is converting back from json, so i don't lose data

dominicm15:01:16

I don't really understand what you mean by "edn" really, edn = clojure data structure once in Clojurescript, no?

danielstockton15:01:16

i mean something like {:a 1 :b 2 :c []} -> ?a=1&b=2&c=%5B%5D

dominicm15:01:15

So, you'd do

(.toString (QueryData/createFromMap {:a 1 :b 2 :c []}))
I think (based on docs)

danielstockton15:01:36

going back is the problem...

danielstockton15:01:31

nevermind, i can write something quite easily, just thought it might already be out there somewhere

joshjones15:01:10

well, it is — compojure/ring/et al for example gives you a nice params map, so i’m sure some existing code exposes this nicely

danielstockton15:01:49

indeed, just need to find it and convert to cljs

dominicm15:01:02

(import '[goog.Uri QueryData])

(let [x (QueryData. "a=1&b=2&c=%5B%5D")]
  (zipmap (.getKeys x) (.getValues x)))

;; => {"a" "1", "b" "2", "c" "[]"}

dominicm15:01:22

Surprised QueryData doesn't have a "getMap", but I might be being thick

dominicm15:01:18

I will note that your input string had "[]" as a string.

dominicm15:01:06

My example also doesn't support repeated keys (which it should)

danielstockton15:01:28

i think i can JSON/parse then js->cljs the values

danielstockton15:01:05

it should but no repeated keys in my case, so i can leave it

danielstockton15:01:01

only thing im losing from cljs actually is proper date types, the rest converts quite easily to/from json

joshjones15:01:11

how about #inst for dates/times?

dominicm15:01:21

(import '[goog.Uri QueryData])

(let [x (QueryData. "a=1&b=2&c=%5B%5D&b=3")]
  (into {}
  (for [k (set (.getKeys x))
        :let [val (js->clj (.getValues x k))]]
    [k (if (= 1 (count val)) (first val) val)])))
;; {"a" "1", "b" ["2" "3"], "c" "[]"}

danielstockton15:01:41

oh, quite nice, thanks 👍

dominicm15:01:35

That's still not perfect..

dominicm15:01:41

how long can I keep improving this 😆

danielstockton15:01:50

don't worry, you've done enough 🙂

danielstockton15:01:54

i have a great start

dominicm15:01:21

My concern is that it should probably be (last val) not (first val) because I think last value wins.

andres-alonso15:01:38

Hi. Has anyone integrated a re-frame app with and existing JS app that's using require JS. Both apps are using require and I get a mismatched anonymous define error

emccue20:01:40

@andres-alonso could you provide a more detailed description of how your app works, and possibly the stack trace?

andres-alonso20:01:27

I'll grab a stack trace when I head back to my desk, but the js app is using require JS and my cljs app is built using re-frame. When I include my app as the first script in the head it works, but I'd like to load it dynamically

emccue20:01:51

Yeah so that sounds like a build system error; to be honest I have had similar errors but the solution is buried somewhere in configuration magic as far as I can tell

emccue20:01:52

The answer lies in using :foreign-libs correctly and writing your externs

andres-alonso20:01:20

This person had a similar issue:

andres-alonso20:01:42

Unfortunately there's no resolution there either

andres-alonso20:01:03

I'll look into to foreign-libs flag thanks

bvs20:01:30

just started delving into clojurescript (+ figwheel), as I want to make use of d3 for plotting. Used several other tools before when making plots in Clojure (lately, used quil). Trying to extend this d3 (v4) version example in clojurescript, and add an axis to the plot, but getting stuck.

bvs20:01:50

from what I read at d3's documentation, it should be as simple as adding two lines to the script. I tried this, and see no errors when figwheel updates the page, but also no axis.

bvs20:01:43

if anyone sees what beginners mistake I make, I'd be happy to know 🙂

bvs21:01:27

inspecting the svg generated by my code, and in the http://bl.ocks.org/mbostock/3883245 example might help me debug. Still getting used to the browser's inspect window.

bvs21:01:16

that helped. Switched the order around of plotting the axis first, and the path second.

selfsame22:01:30

is there a clj version of cljs's IPrintWithWriter

selfsame22:01:00

(always find protocol documentation impossible to find online)

selfsame22:01:08

also stuck on IWithMeta

dnolen22:01:38

@selfsame not a protocol, print-method multimethod I think

selfsame22:01:23

aha, thanks!