This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-03
Channels
- # beginners (112)
- # boot (13)
- # cider (17)
- # cljsjs (2)
- # cljsrn (8)
- # clojure (57)
- # clojure-spec (2)
- # clojure-uk (5)
- # clojurescript (51)
- # cursive (4)
- # data-science (15)
- # datomic (1)
- # duct (17)
- # garden (4)
- # lein-figwheel (49)
- # midje (1)
- # nyc (1)
- # off-topic (8)
- # pedestal (1)
- # portkey (20)
- # re-frame (4)
- # reagent (27)
- # ring (1)
- # shadow-cljs (24)
- # spacemacs (7)
- # specter (3)
- # sql (5)
- # yada (5)
hm that might have been a red herring. I’m also using shadow-cljs, which treats npm deps way differently than cljsbuild
https://clojureverse.org/t/nested-reagent-atoms-not-redrawing/2213 do you have any ideas about it?
@lilactown if you need to emit #js ...
from a macro you must emit ~(cljs.tagged-literals/JSValue. {:hello "world"})
directly. since the reader is already done you cannot do this via manipulating that. your macro must emit the correct value. the above is equivalent to #js {:hello "world"}
when written in CLJS.
Hi, any idea how to slurp files from jar file / classpath?
ATM my code reads from file system with http://lumo.io/slurp - in clojure I would use (slurp (
- how I can do this in cljs ?
@jerger I've implemented this in Planck (which is self-hosted, like Lumo), so you could copy the relevant bits of Plank's implementation.
after reading some source I found the answer 🙂
(
@mfikes do u have a github url?
@jerger_at_dda Planck pulls it off by implementing the IOFactory
stuff that is in Clojure, so a lot of it is in here https://github.com/planck-repl/planck/blob/master/planck-cljs/src/planck/io.cljs
okay ... understand ... planck provides a c function, PLANCK_LOAD_FROM_JAR wraps it and io.cljs uses it ... Is there some kind of RFC how planck or lumo extract jars to be able to read resources or does every implementation its own handling?
Well, since there is no slurp
or io/resource
in ClojureScript, it is up to each implementation to roll its own solution.
@roti, are they better than native promises in any way? or why are you interested in them?
i don't know much about native promises, but I guess the google ones are more browser independent. apparently there's also a performance factor involved: http://funcool.github.io/promesa/latest/#why-bluebird-instead-of-es6-promise
I don't think browser independent is much of a concern anymore (plus you can use shims if necessary)
if you're writing new code, I'd stick to es6 promises
Promises are actually quite pleasant to use from Cljs IMO: (-> (promise-returning-fn) (.then ...) (.then ...))
@mfikes I think it would be great if clojurescript had a slurp
it can work with fs
on backend and in browser using xhr
atleast this is how it works in clojure. so that one can do (slurp “
Yeah that is a big problem.
May be a (slurp "/some/path" #(callback-function))
can work.
Check out abio
😄
Haha interesting! 😃
oh, sorry, actually, I should say, if you are using shadow-cljs it’s fine because it infers externs
i’m not sure how good externs inference is on the mainline compiler now. before I moved to shadow i used cljs-oops
to do js interop access to avoid the externs issue.
Both (.-some)
and (aget coll 'key')
can be used.
well the official take on aget
is that we’re not supposed to use it for property accessors anymore
@lilactown it works great. you do have to do some light type hinting sometimes, but the compiler will warn you if it can’t figure it out so that you don’t miss any: (defn [^js obj] (.-foo obj)
like e.g. I have (.. this -state -baz)
where state
is JS and baz
is defined by userland
Would the facilities described here https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules be able to pull in https://nodejs.org/api/stream.html in a browser setting? Or is that strictly only going to work when targeting nodejs?
@jsa-aerial the reverse actually: it is intended to bring npm modules into the closure compiler and ship them to the browser. note, that the feature describes is really quite experimental. if you want a robust and reliable way of using npm modules on the browser, use shadow-cljs
for your build tool
you’re asking a more specific question about stream. no you cannot use the stream api on the browser using any tool because the browser won’t allow you to
@jsa-aerial that’s a native Node.js API, it does not work in the browser. you could possibly find a JS library that implements something similar that works in the browser
@lilactown @lee.justin.m That's what I was afraid of. I think this http://highlandjs.org/ would work as replacement ...
@jsa-aerial what are you trying to do exactly? I don’t think highland is really related to Node.js streams
@lilactown It's just the stream part of nodejs streams - actually just the Transform part of that. It is used in cljs-msgpack-lite. So, to start I think the idea is to split off the stream stuff from the basic msgpack stuff, then redo the stream Transform stuff with highland (which seems to have basically the same capability, but runs in both node and browser)