Fork me on GitHub
#clojurescript
<
2016-09-27
>
royalaid00:09:00

I started a new project and moved over the relevant parts of the code and it seems to have fixed my issue. Thanks for pointing me the right direction @dnolen

navigator.getUserMedia = function () {};
navigator.mediaDevices.getUserMedia = function () {};
works for the simple case of what I am trying to do

royalaid00:09:35

I am not sure why but in the other project the global navigator object seemed to be getting stomped over

royalaid00:09:50

and so the app.js wouldn't run

Jon02:09:43

can we lazy load js code compiled by ClojureScript as we change the router in a browser?

nowprovision07:09:28

whats the current idiomatic js interop story to iterate (probably via doseq) over goog.dom.getElementsByClass('mdl-item') and apply window.componentHandler.upgradeElement(item) to each.. ?

nowprovision07:09:13

iirc doing something like (js/goog.dom.getElementsByClass "blah") is frowned upon?

reefersleep08:09:57

In the frontend part of our reagent application, we have had a habit of accumulating values into a map which is then passed on from component to component. Some of the values are only relevant for logical purposes, and a subset are relevant for passing on to the final "leaf" component, such as an `[:input]` or `[:span]` or whatever. Since we bumped our reagent version, and transitively our React version, React has been outputting warnings about for example: _react.inc.js:20209 Warning: Unknown prop `iconDisabled` on &lt;span&gt; tag. Remove this prop from the element. For details, see <https://fb.me/react-unknown-prop_> (edited) This is because we pass our saturated map directly to the leaf component. Now, I'm trying to figure out which would be the better solution. Destructuring the saturated map for only the values that we are interested in seems like the most sane solution, but it leads to having to add more stuff to the destructuring as we go along, and it seems silly to do all this only to recreate the part of of the map that we are interested in before passing it to the component. It seems like a lot of boilerplate. And having to add to that boilerplate along the way seems silly, too. So I thought, since the "legal" values for a particular element type are already known, perhaps someone has created a vetting function? Something like `(sanitize-for :span saturated-map)`

pseud09:09:39

I’m curious, cljs.spec/or will output a vector containing the tag of the match, e.g. (s/conform (s/or :nil nil? :fn fn?) nil) => [:nil nil] Also, specs can be written to be recursive. The result is that I can recursively validate a map AND get a modified structure in which each value (almost) is a vector containing a tag and the value itself. I.e. I can a) validate the structure of my input b) gain a structure which makes it easy to conditionally process each value (e.g. decide which fn to apply to the value based on the tag) How do others feel about using conform to do this ?

bahulneel10:09:49

@pseud I'm doing this with some success at present

pseud10:09:17

@bahulneel good to know I’m not alone 😉

bahulneel10:09:25

@pseud I do believe this is one of the specific intended ways to use spec.

yury.solovyov10:09:59

what's the popular libraries for client-side persistent storage?

yury.solovyov10:09:33

maybe some indexdb wrappers?

kalouantonis10:09:07

You mean like datascript?

yury.solovyov10:09:41

maybe, I'm not sure if it saves data on disc

reefersleep10:09:59

@pseud @bahulneel: I believe Stuart Halloway mentions this in his StrangeLoop talk: https://www.youtube.com/watch?v=VNTQ-M_uSo8&amp;t=33m58s

kalouantonis10:09:45

@yury.solovyov: Probably not, the README writes this >>> No facilities to persist, transfer over the wire or sync DB with the server

bahulneel10:09:49

@reefersleep @pseud I think that's where I got the idea from, it's saved me unimaginable amounts of time and effort already.

kalouantonis10:09:31

I’ve only used localStorage with my electron apps, so I’m not sure what the best approach is. The first thing that springs to mind is sqlite

pseud10:09:48

@reefersleep @bahulneel : super - I was going to do it unless some extremely insightful point in opposition to it was raised, but it seems not 🙂

pseud11:09:10

@bahulneel sounds interesting, bookmarked the talk 🙂

pieterbreed11:09:01

Hello everyone. Does anyone have advice for me, please? I need to build a proof-of-concept android app, that will talk to a clojure-based server-side component. I'm hoping that there exists a good android story for clojurescript and that someone here will be kind enough to point me to the resources or advice that will help me avoid pitfalls and time-wasting (yak-shaving).

pseud11:09:18

pieterbreed: don’t know about clojurescript in particular, but phonegap / cordova are JavaScript frameworks targeting & abstracting away the host platform. That way I believe you’ll target even more than just Android phones. From that point… well, clojurescript compiles to JavaScript so it’s essentially a question of interop’ing with the phonegap/cordova frameworks. Maybe someone’s written some nice wrapper libraries already, if not, well then I guess you have your work cut out for you 🙂

pieterbreed11:09:58

thank you @pseud, I'll check that out

reefersleep11:09:06

What about react native, does that work for Android?

pseud11:09:05

It’s getting closer, I think. Thought about using it in our former place of work, but Android was very much a second thought for them back then, perhaps it’s gotten great now, though

reefersleep11:09:51

I've heard that error messages are very poor for natal/re-natal in general and that it is confusing, but then, confusing error messages are our bread and butter...

anmonteiro11:09:35

@pieterbreed in any case you might have better luck with the experts in #cljsrn 🙂

pieterbreed11:09:29

I posted a message there too, tx 🙂

dnolen13:09:53

@nowprovision there’s nothing wrong with using Google Closure like that to do this

dnolen13:09:49

however you don’t want to do stuff like js/goog.dom…, there’s no need - (gdom/…) for example if you aliased goog.dom to gdom in your ns form

dominicm13:09:05

@dimovich late to the party, but things like https://crossorigin.me/ exist to help with this

dnolen14:09:52

@jiyinyiyong yes that’s what Closure Modules are for - code splitting so you can separate code between pages as well as for lazy loading.

dnolen14:09:11

the new ClojureScript site could really use a guide on modules + lazy loading (hint, hint)

dominicm14:09:08

https://rasterize.io/blog/cljs-dynamic-module-loading.html Is using goog.module on page change the correct way to lazy load modules? Might help whoever writes that guide.

Alex Miller (Clojure team)14:09:25

I think Maria started working on moving some of her stuff already https://github.com/clojure/clojurescript-site/issues/26

shaun-mahood16:09:56

Interesting article about JS backdoors, I assume it can also apply to Google Closure and advanced mode compilation - https://diracdeltas.github.io/blog/backdooring-js/ I'm not particularly concerned or well informed though, but it may be relevant to someone's interests or needs. I figure this is probably another good reason to prefer the Closure compiler to other minification options, though.

pat16:09:15

@shaun-mahood that is a cool article

tomjkidd17:09:39

@dnolen The Next Five Years of ClojureScript talk was really enjoyable. Your viewpoint of web development in 2011 was cool to hear, that is around when I started and it has been pretty insane all the change in the space. I am grateful to all of the devs that have contributed to making ClojureScript as good as it is now.

dnolen17:09:50

Glad you enjoyed it! The ClojureScript community rocks :)

mac17:09:22

How do I bind the resolved return value (in this case a json object) of a Javascript promise in a let block? all I get is a #object[Promise [object Promise]]

mac17:09:19

I mean why does (.then (fn-that-returns-a-js-promise) #(print (.-prop %))) print the value of .prop to the repl while (let [prop (.then (fn-that-returns-a-js-promise) #(.-prop %))] prop) prints #object[Promise [object Promise]]?

Yehonathan Sharvit17:09:34

I need help with cljs-http: My response is in transit json and I need to convert it to edn. cljs-http automatically converts the json into a cljs object.

Yehonathan Sharvit17:09:50

So for the moment, I am doing:

(-> json
      clj->js
      js/JSON.stringify
      (transit-decode :json nil))
But I'm sure there is a better way.

pat17:09:16

@viebel is it using response headers to automatically convert?

johanatan17:09:07

I know that reverse debugging has been demonstrated in Clojure but has it been developed into a sort of more polished form a la elm-reactor (https://github.com/elm-lang/elm-reactor) ? Is this a question that's more appropriate for #om or #reagent ?

pat17:09:21

@viebel headers are arbitrary so i'd try making up your own and see if it gets through

christianromney18:09:55

@viebel i'm assuming you can't just send edn from the server?

Yehonathan Sharvit18:09:33

Yes! It’s the cache data from clojurescript and it is stored in transit-json

Yehonathan Sharvit18:09:17

@christianromney - when I wrote “Yes!” I meant that your assumption is right => I can’t send edn

christianromney18:09:50

ok i'm having trouble then picturing exactly where you want to convert to edn in that pipeline. but might this work for you? (pr-str the-cljs-obj)

Yehonathan Sharvit18:09:17

@christianromney the data is stored in transit-json format and I need it in edn

christianromney18:09:53

right i meant since you're pulling it and it's automatically being converted by clj-http into a cljs object

christianromney18:09:14

just call (pr-str ) on the returned obj

Yehonathan Sharvit18:09:36

It returns mean the json as a string and then I need to decode it with transit

Yehonathan Sharvit18:09:41

This is what I’m doing

christianromney18:09:53

are you married to cljs-http?

christianromney18:09:02

cljs-ajax does all the conversion for you

Yehonathan Sharvit18:09:04

I’m looking for a way to avoid deserializing twice

Yehonathan Sharvit18:09:16

Not married to cljs-http

christianromney18:09:46

i don't see how you'll get around the double conversion

christianromney18:09:52

since the server is sending transit json

christianromney18:09:02

which compresses

Yehonathan Sharvit18:09:12

I need to find a way to tell cljs-http not to parse the json

Yehonathan Sharvit18:09:18

and to leave it as a string

christianromney18:09:52

you can do a lower-level call, but that json will be garbage if you try to just turn it into edn

Yehonathan Sharvit18:09:23

I know, I will use transit-decode

Yehonathan Sharvit18:09:55

Do u know how to do a lower-level call in cljs-http?

christianromney18:09:37

ok but transit-decode will return an object, right?

christianromney18:09:38

transit json -> transit-decode -> cljs data structure -> pr-str -> edn

christianromney18:09:05

unless you want to build some special decoder that transforms transit json wire format natively into equivalent edn there's no way around it

Yehonathan Sharvit18:09:15

cljs data structure is fine for me

christianromney18:09:47

ok in that case, cljs-ajax will decode for you automatically. so you'll just get back cljs data from a transit response

christianromney18:09:18

you can also register handlers if you need to

christianromney18:09:27

for custom transit types