Fork me on GitHub
#clojurescript
<
2016-09-22
>
rmuslimov10:09:02

Hi, channel! Is there any good alternatives to secretary lib (https://github.com/gf3/secretary#example-with-googhistory) in cljs?

martinklepsch10:09:04

@rmuslimov there's pushy which integrates with multiple routing libs: https://github.com/kibu-australia/pushy

martinklepsch10:09:58

But also making your own on top of goog.History is reasonable. Take a look at pushy's implementation and you'll see it's actually not a lot of code

juhoteperi10:09:00

@martinklepsch No, using bidi currently

pesterhazy10:09:22

I'm happily using bidi too

martinklepsch10:09:05

It's also my goto routing lib but the point in bide's readme that bidi routing specs are hard to read can't be denied

jcb11:09:09

super basic - I'm trying to access object properties of html5 media elements like .-volume but I can't read/change them. Any ideas? thanks!

pesterhazy12:09:43

@martinklepsch challenge accepted: I find them easy to read

martinklepsch12:09:09

good for you 😂

dominicm12:09:07

The problem with bide, is that somewhere someone is parsing that string. I find that harder to trust than "parsing" a vector

jcb14:09:15

does anyone have any advice on how I can change properties of video tag in cljs please?😅

miguelb14:09:24

@jcb you can do a github code search with what you’re asking about and filter by the cljs extension

miguelb14:09:42

I do it all the time to see how people use much of google closure lib

jcb14:09:15

Thanks, I've had a look and the only project I found was one from 2013 with a backbone.js backend that was very confusing

pesterhazy14:09:24

change properties of an object with set!: http://cljs.github.io/api/cljs.core/#setBANG

pesterhazy14:09:10

that's if you know how to do it in js, it's just a matter of translating line by line

jcb14:09:44

I think that's my main problem

jcb14:09:16

thanks @miguelb I'd been filtering by clojure instead of extension

miguelb14:09:18

that happens to me all the time

miguelb14:09:52

credit goes to the clojurescript wiki, its the section on google closure library

jcb14:09:23

I'm finding the translation part the hardest to get my head around

jcb14:09:02

I've read that using aset and the .- notation together can cause compilation problems?

jcb14:09:29

can anybody clarify which is best to use and why?

domgetter15:09:18

Does cljs distinguish between 0 and -0 ?

darwin15:09:25

cljs numbers are js numbers, your question should be answered by http://stackoverflow.com/questions/7223359/are-0-and-0-the-same

domgetter15:09:39

Hmm, running (/ 1 -0) on http://clojurescript.net/ returns Infinity instead of -Infinity. Is this a bug?

juhoteperi15:09:03

No, that is how JS works

domgetter15:09:16

No, 1/-0 is -Infinity in JS

domgetter15:09:07

Furthermore, http://Object.is(0, -0) returns false in JS, but (js/Object.is 0 -0) returns true on http://clojurescript.net

dnolen15:09:07

@domgetter you cannot use bootstrapped ClojureScript projects to determine actual behavior

dnolen15:09:35

that particular one is way out of date

dnolen15:09:56

so asking questions based on that - not productive

domgetter15:09:43

I just started up a 1.9.229 repl, and it's the same behavior. Should I submit a bug report, or is this intended behavior?

juhoteperi15:09:14

@domgetter check compiled project, not repl

dnolen15:09:15

ClojureScript numerics are just JS numerics

dnolen15:09:59

@domgetter a bug report is possible here but only after trying this in multiple engines

dnolen15:09:26

and by starting up a REPL you should be using no extra tooling

darwin15:09:27

(planck) so it might be planck problem

mfikes15:09:43

FWIW, looks like it occurs in the ClojureScript Node REPL.

dnolen15:09:51

I just took a look, it does look an edgecase around the -0 literal

dnolen15:09:08

it always gets compiled to 0 likely because it reads as Java Long

dnolen15:09:46

so sure file a JIRA minor ticket about the -0 literal - seems pretty newbie friendly too, so patch welcome

domgetter15:09:33

Awesome. Sorry if I didn't follow procedure. I'll look up documentation on cljs contribution.

dnolen15:09:18

also compiler dev discussion usually happens in #cljs-dev

jcb17:09:28

how do I access functions like requestFullScreen? I thought that would be included in the closure lib? My editor and figwheel are unhappy

jjfine17:09:38

it's a javascript function on an element so does (.requestFullScreen element) work?

jcb17:09:27

editor doesn't understand it

jjfine17:09:10

yeah, i think that's to be expected

jcb17:09:34

do I have to wrap it?

borkdude18:09:43

Why does this replace all characters in this string? (str/replace "a-b-c" #"[^\p{L}\p{Nd}]+" “”) ;;=> “"

dnolen18:09:47

@borkdude did you try it in JS?

borkdude18:09:35

that’s like "a-b-c".replace(/[^\p{L}\p{Nd}]+/,””) in JS right? I tried it in clojure (JVM), but maybe they have different regex rules

dnolen18:09:19

@borkdude yes because JS regular expressions and Java regular expressions are two completely different things

domgetter18:09:37

@borkdude I couldn't get "asdf".replace(/\p{L}/, "") to work in JS. so I think your original is replacing all characters since everything is not any of the "meaningless" \p characters.

borkdude18:09:53

@domgetter thanks, I have reverted to this now:

(defn remove-non-word-chars [s]
  (str/trim (str/replace s
                         #?(:clj #"[^\p{L}\p{Nd}]+"
                            :cljs #"[\W_]+") " ")))

liamd18:09:57

why does this code:

(dom/img #js {:src image-url :style {:width "150px" :height "150px"}})
generate this invalid style attr:
style="cnt:2px;arr::width,150px,:height,150px;cljs$lang$protocol_mask$partition0$:16647951px;cljs$lang$protocol_mask$partition1$:8196px;”
? am i missing something here?

dnolen19:09:31

@liamd yes #js isn’t recursive

liamd19:09:56

ah so i add #js to each submap, got it

liamd19:09:06

that did the trick

jamesmintram19:09:33

I have been figuring out how the use a commonJS module (generated using webpack) inside of clojurescript - and this is what I have ended up with when calling an exported function named CreateWSConn:

(ns blah (:require [testlib]))

 ((.. js/testlib -CreateWSConn))
It works.. but I wondered if this is idiomatic?

dnolen19:09:30

@jamesmintram if it can’t go through Google Closure - yes

jamesmintram19:09:30

I have included it in the foreign-libs section of project.clj:

:foreign-libs [{:file "resources/bundle.js"
                                    :provides ["testlib"]
                                    :module-type :commonjs}]
and the first line of the bundle.js in compiled/out is below. I don't know if that means it has gone through Google Closure?
goog.provide("module$resources$bundle");var exports$$module$resources$bundle=module$resources$bundle;

jamesmintram19:09:52

I guess a higher level question would be, I am not even sure what it would look like in the ideal case. Should I be able to call exported functions like this:

(.CreateWSConn js/testlib)

dnolen19:09:52

if you are processing it via the CommonJS support, then no that require is not right

dnolen19:09:18

if you go through Google Closure then you require in the normal way

dnolen19:09:58

you shouldn’t need global access like that

jamesmintram19:09:00

Awesome! It works. Thanks 🙂 I have struggled to find any definitive documentation or example showing how it all fits together, and the the significance of using the CommonJS support (at least all in one place) Are you aware of any such documentation? If not, it could be a good excuse for me to write an example or documentation of some kind.

dnolen19:09:23

no, it needs to be documented

dnolen19:09:30

preferably on the new website

dnolen19:09:50

the documentation should be clear that the functionality is in alpha state however and subject to change