This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-27
Channels
- # arachne (1)
- # beginners (31)
- # boot (84)
- # cider (9)
- # clara (2)
- # cljs-dev (102)
- # cljsrn (20)
- # clojure (254)
- # clojure-belgium (1)
- # clojure-dusseldorf (17)
- # clojure-greece (7)
- # clojure-italy (6)
- # clojure-russia (2)
- # clojure-spec (8)
- # clojure-uk (9)
- # clojurescript (93)
- # component (4)
- # copenhagen-clojurians (1)
- # cursive (24)
- # datomic (22)
- # editors (1)
- # emacs (8)
- # garden (2)
- # hoplon (357)
- # lein-figwheel (1)
- # leiningen (4)
- # luminus (27)
- # mount (13)
- # off-topic (7)
- # om (71)
- # onyx (35)
- # planck (3)
- # re-frame (53)
- # reagent (35)
- # ring-swagger (24)
- # specter (10)
- # sql (6)
- # untangled (47)
- # vim (157)
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 doI am not sure why but in the other project the global navigator object seemed to be getting stomped over
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.. ?
iirc doing something like (js/goog.dom.getElementsByClass "blah") is frowned upon?
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 <span> 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)`
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 ?
@bahulneel good to know I’m not alone 😉
what's the popular libraries for client-side persistent storage?
maybe some indexdb wrappers?
You mean like datascript?
maybe, I'm not sure if it saves data on disc
@pseud @bahulneel: I believe Stuart Halloway mentions this in his StrangeLoop talk: https://www.youtube.com/watch?v=VNTQ-M_uSo8&t=33m58s
@yury.solovyov: Probably not, the README writes this >>> No facilities to persist, transfer over the wire or sync DB with the server
@reefersleep @pseud I think that's where I got the idea from, it's saved me unimaginable amounts of time and effort already.
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
@reefersleep @bahulneel : super - I was going to do it unless some extremely insightful point in opposition to it was raised, but it seems not 🙂
:thumbsup:
@pseud This influenced me a lot https://www.youtube.com/watch?v=ZQkIWWTygio also
@bahulneel sounds interesting, bookmarked the talk 🙂
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).
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 🙂
thank you @pseud, I'll check that out
What about react native, does that work for Android?
It does, I guess: https://github.com/drapanjanas/re-natal
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
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...
@pieterbreed in any case you might have better luck with the experts in #cljsrn 🙂
I posted a message there too, tx 🙂
@nowprovision there’s nothing wrong with using Google Closure like that to do this
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
@dimovich late to the party, but things like https://crossorigin.me/ exist to help with this
@jiyinyiyong yes that’s what Closure Modules are for - code splitting so you can separate code between pages as well as for lazy loading.
@dnolen https://swannodette.github.io/2015/02/23/hello-google-closure-modules looks like you have a great tutorial on this!
the new ClojureScript site could really use a guide on modules + lazy loading (hint, hint)
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.
I think Maria started working on moving some of her stuff already https://github.com/clojure/clojurescript-site/issues/26
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.
@shaun-mahood that is a cool article
@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.
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]]
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]]
?
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.
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.I opened an issue on github: https://github.com/r0man/cljs-http/issues/103
I think so https://github.com/r0man/cljs-http/blob/master/src/cljs_http/client.cljs#L177-L182
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 ?
@viebel i'm assuming you can't just send edn from the server?
Yes! It’s the cache data from clojurescript and it is stored in transit-json
@pat will try tomorrow
@christianromney - when I wrote “Yes!” I meant that your assumption is right => I can’t send edn
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)
@christianromney the data is stored in transit-json format and I need it in edn
right i meant since you're pulling it and it's automatically being converted by clj-http into a cljs object
whoooaaaaa, i didn’t know https://github.com/mneise/clojurescript-site/blob/master/content/reference/javascript-module-support.adoc was already in cljs!
just call (pr-str )
on the returned obj
It returns mean the json as a string and then I need to decode it with transit
This is what I’m doing
oh i see
are you married to cljs-http?
cljs-ajax does all the conversion for you
I’m looking for a way to avoid deserializing twice
Not married to cljs-http
i don't see how you'll get around the double conversion
since the server is sending transit json
which compresses
I need to find a way to tell cljs-http not to parse the json
and to leave it as a string
you can do a lower-level call, but that json will be garbage if you try to just turn it into edn
I know, I will use transit-decode
Do u know how to do a lower-level call in cljs-http?
ok but transit-decode will return an object, right?
not edn
transit json -> transit-decode -> cljs data structure -> pr-str -> edn
unless you want to build some special decoder that transforms transit json wire format natively into equivalent edn there's no way around it
cljs data structure is fine for me
don’t need edn
ok in that case, cljs-ajax will decode for you automatically. so you'll just get back cljs data from a transit response
you can also register handlers if you need to
for custom transit types