Fork me on GitHub
#clojurescript
<
2016-04-21
>
dmh4302:04:43

How do most people run their cljs tests?

dmh4302:04:17

I’ve been using doo, but doo won’t report full stack traces when an error occurs in the test which limits the helpfulness of tests sometimes

sonnyto02:04:17

has anyone used google polymer with clojurescript?

danielcompton03:04:41

@dmh43: I’ve used Karma directly which works pretty well

dmh4303:04:15

And you write your tests with cljs.test?

tom03:04:50

I'm trying to load a script from vimeo's and on my first attempt here I've added it into the DOM as a <script>. It shows up in debugging in the DOM but is not actually loaded and claims that the Vimeo var isn't loaded. I'm using Reagent but I don't think that's what's going on. Is there some Browser/JS/Cljs thing I might be overlooking?

danielcompton03:04:56

I need to write a blog post about it

dmh4303:04:02

@danielcompton: oh cool. Thanks!

danielcompton03:04:50

@tom your description is a bit vague, you might need to give some more details

tom03:04:39

(defn vimeo-js-api []
  [:script {:src ""
                   :type "text/javascript"}])
And when that's rendered in with other components it shows up when inspecting elements. However, the sources and network don't show it as getting loaded. If I hardcode the script into the HTML head then it does load.

grav08:04:34

Anyone using doo for testing?

danielcompton08:04:06

@grav yep, I’ve used it in the past and still have a project on it

grav08:04:42

@danielcompton: I have a problem with external dependencies. I’m running with phantomjs as runner, and if I do not set my target's :optimizations to :whitespace, it cannot find Google Closure (eg ReferenceError: Can't find variable: goog)

grav08:04:17

(edit: if i do not set :optimizations to :whitespace)

danielcompton08:04:33

yikes. I haven’t used phantomJS with Doo, does it do the same with the Chrome Karma runner?

grav08:04:53

Ah, ok. I’ll maybe try with another runner

grav08:04:47

@danielcompton: is there an easy way to getting started with Chrome Karma?

grav08:04:53

I have not heard about it before

danielcompton08:04:27

It’s a pain if you’re on windows, but ok on OS X or Linux

grav08:04:30

Hehe, ok! Thanks!

mattyulrich09:04:01

Anyone have a thought on the best way to initialize a server call based on a change to app-state in om.next?

mattyulrich09:04:40

ie. After a user logs in (change to app-state), fetch other information about the world from that user’s perspective?

mattyulrich12:04:52

Ok - I think the way to go is to follow the pattern in the remote synchronization tutorial; but I am a bit confused about how the reconciler invokes the :send method.

mattyulrich12:04:44

In the remote synchronization tutorial section demonstrating how to make an auto-complete search widget, they suggest the following read function: `(defmethod read :search/results [{:keys [state ast] :as env} k {:keys [query]}] (merge {:value (get @state k [])} (when-not (or (string/blank? query) (< (count query) 3)) {:search ast})))`

mattyulrich12:04:10

I see that “:search” is registered in this example as one of the remotes - does this mean that the result of this read function triggers the reconciler to attempt to read :search and thereby trigger the :send function for remote reading?

dnolen12:04:21

@mattyulrich: there’s an #C06DT2YSY specific channel

mattyulrich12:04:32

Oh - thanks.. switching there.

lwhorton16:04:48

can someone explain to me why a compilation of :advanced throws Uncaught TypeError: re-find must match against a string. in the following example? (capturing status from xhrrequest using google xhrio lib)

(def api {:login "/api/login"})
(defn capture [response]
  (if (> (.. response -xhr_ -status) 299)
    response
    (let [url (.. response -xhr_ -responseURL)
          capture? (re-find (re-pattern (:login api)) url)]
      (when capture? ...))))
If I do some debugging, it looks like url is undefined/null in the javascript… which makes me think the compilation is somehow bashing response.xhr_.status?

lwhorton16:04:38

I was hoping I wouldn’t need to do the whole externs.js stuff, particularly because i’m using the closure xhrio lib and not some third-party.

martinklepsch16:04:44

@lwhorton: the _ usually indicates that thing_ is private in Closure. I'm not sure if externs could work differently in this case but maybe try finding a "non-underscore" way...?

martinklepsch16:04:19

@lwhorton: I have never needed externs for anything coming from closurelib

lwhorton16:04:37

Hmm.. okay thanks. I’ll take a closer look.

lwhorton17:04:11

hah, silly me… i’m in there rooting around in internals and the closurelib has a whole bunch of .get{accessor} methods.

lwhorton17:04:29

yup @martinklepsch that was exactly the problem, thanksa gain.

nidu18:04:54

Hello, is it normal that (clojure.set/union #{1 2} [3 4]) returns #{1 2 3 4} but (clojure.set/union #{1 2} [3 4 5]) returns [3 4 5 1 2]?

jr18:04:13

yes. union begins with the largest collection

mfikes18:04:11

Also the docs say "input sets”, so without that precondition, undefined land.

nidu18:04:11

Yeap, seen about sets but behaviour looks interesting at first

nidu18:04:31

So when you try it on simple input set and vector and it works - it seems that it will work on all vectors.

nidu18:04:56

@jr: does it mean that if i union sorted set with simple set - behaviour will change depending on sets sizes?

jr18:04:23

behavior is the same if you use sets as the inputs

nidu18:04:08

I mean if i use one sorted set and one non sorted.

jr19:04:41

ah yeah that’s won’t work

dnolen19:04:35

@nidu right passing in anything other than sets is undefined as @mfikes said, and no guarantee about preserving the type of set

nidu19:04:02

@dnolen: totally understand. Just thought it might work, Clojure methods often allow multitude of different parameters as i tend to think

dnolen19:04:03

@nidu yeah doesn’t work, and far as I know, intentionally

fenton19:04:05

Anyone have issues storing a nested map into the browsers localStorage?

pyr19:04:34

Hi everyone

fenton19:04:36

I seem to get back an empty object when i try to retrieve my nested map?

pyr19:04:05

I wonder if there is work out there similar to @mfikes has done with JavascriptCore which targets v8

pyr19:04:19

Or if it's still an exercice that's left to the reader

fenton19:04:45

ah i c i have to stringify it... cool simple_smile

dnolen19:04:57

@pyr def exercise left for the reader, Planck uses embedded JSC and provides I/O

mfikes19:04:56

@pyr: If you want a bootstrap REPL that runs in Node, there is the following. It works, but it has not had any real effort or polish put into it: https://github.com/mfikes/elbow

mfikes19:04:36

It is really nothing more than a small wrapper around Replumb.

pyr19:04:42

mfikes: thanks, will look at it

pyr19:04:20

@dnolen: it's a good exercise nonetheless simple_smile

richiardiandrea19:04:27

about bootstrap test

richiardiandrea19:04:41

I was thinking of adding something to replumb

richiardiandrea19:04:55

actually we were discussing with Mike to either spawn a new project or add stuff to replumb and I am kind of torn because maybe I am putting too many things in replumb

mfikes21:04:34

Yeah, the thinking is that libs that want to ensure compatibility with bootstrap ClojureScript (by running their existing cljs.test tests in a bootstrap environment), will want an easy way to achieve that. https://github.com/mfikes/titrate illustrates that it is possible, but there is a lot of boilerplate that can probably be factored out into a lib that the community can use.

lwhorton21:04:52

can I rubber-duck someone about a good way to use specljs with closure?

lwhorton21:04:14

specljs offers a cli, and their recommended cljs setup is to use a runner.js file that pulls in phantom, then uses phantom’s injectJs and evaluate to injec the compiled spec files, then evaluate the result of running those specs.

lwhorton21:04:53

let’s call that runner file /bin/speclj… we can’t directly invoke speclj /target/main.js because the mainjs file is expecting to be run where there is a document, and it dynamically attaches a cljs_deps.js followed by goog.require(‘namespace.someUUID’).

lwhorton21:04:23

i dont think phantomjs allows you to do stuff like document.write(‘<script src …’). because the closure main.js file changes after each compile, we need a way to get that file (and the consequently required compiled cljs code) into a phantom environment so we can run the speclj against it.

telent21:04:43

bookshlv.core=> (into #{}  [(Uri. "") (Uri. "")])
#{#object[Object ] #object[Object ]}
bookshlv.core=> (clojure.set/union *1)
#{#object[Object ] #object[Object ]}
bookshlv.core=> (apply = [(Uri. "") (Uri. "")])
false

telent21:04:22

this is ... awkward. can I make it treat two uris for the same resource as equal?

jswart21:04:03

or maybe (apply (comp = str) …

jswart21:04:08

but that seems more hacky

jswart21:04:03

hmm also just realized this is the cljs channel, 😞

telent22:04:04

yeah, I want something that will work with uris as set members etc, though

telent22:04:39

looks like I should extend-type IEquiv

telent22:04:46

(extend-type Uri
  IEquiv
  (-equiv [o other]
    (and (instance? Uri other)
         (== (.toString o) (.toString other)))))
; now
(into #{}  [(Uri. "") (Uri. "")]) 
=> #{#object[Object ]}