This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-18
Channels
- # announcements (26)
- # beginners (107)
- # calva (26)
- # cider (55)
- # clj-kondo (7)
- # clojure (115)
- # clojure-europe (6)
- # clojure-houston (3)
- # clojure-italy (4)
- # clojure-nl (16)
- # clojure-norway (1)
- # clojure-uk (42)
- # clojuredesign-podcast (3)
- # clojurescript (47)
- # clojutre (4)
- # cursive (7)
- # datomic (75)
- # fulcro (1)
- # graalvm (3)
- # graphql (16)
- # jobs (1)
- # jobs-discuss (13)
- # keechma (1)
- # leiningen (19)
- # luminus (5)
- # off-topic (33)
- # pathom (16)
- # re-frame (76)
- # reitit (4)
- # ring (5)
- # shadow-cljs (86)
- # spacemacs (52)
- # tools-deps (43)
- # vim (7)
- # yada (1)
ended up going with
(.log js/console "Lesson " (.getAttribute (. js/document (getElementById "imprt")) "data-lesson"))
(.log js/console "Section " (.getAttribute (. js/document (getElementById "imprt")) "data-section"))
(.log js/console "Lesson Type " (.getAttribute (. js/document (getElementById "imprt")) "data-lesson-type"))
<div data-lesson="1"></div>
Hello everyone
I wanted to interact with a git repository (gitlab) which API's would you suggest could work good for this?
I have never used any APIs for accessing git repos before, but I have heard of a Clojure library called tentacles that you could see if it does anything useful for you: https://github.com/clj-commons/tentacles Warning: according to its README it interacts with a Github API, so that library might be specific to Github, and if so, might not work with the gitlab web site.
Thanks andy! I will take a look.
are goog.event/listen
ers garbage collected when the thing they are listening to is collected or must we take care to also clean these up? Its trivial to do i suppose but a bit ugly so i prefer not to if its all the same
I don't think that's really a question for goog.event/listen
but whether you're attaching events to the DOM period
Isn’t best practice here not to attach listeners to individual dom nodes but to the “root” node and filter there? Something like delegated event handlers in jquery (See https://api.jquery.com/on/)
that was at times when event listeners where expensive in browsers IE6 I guess
thanks for the context @roman01la
Is there no cljs.edn nor clojure.edn namespace available in cljs? I thought there was, because I was using it in a .cljc file without error before, but perhaps there was a warning and I missed it?
since v0.0-927
Thanks!
Yeah, it is weird, because I have some cljs deftest-based test namespace that require's clojure.edn that I never noticed errors with before, but perhaps I wasn't looking closely enough. Thanks for the help.
could someone help me understand what's going on with this code? what's really confusing is how the resp-json
argument passed to the then
callback is a javascript object, but the resp-json
argument passed to catch
is a promise; that seems wrong somehow
(defn fetch-and-then [url]
(-> (js/fetch url (clj->js {:headers {"Accept" "application/json"}}))
(.then (fn [resp]
(js/console.log "resp ok? " (.-ok resp))
(js/console.log "resp" resp)
(let [json (-> resp .json)]
(if (.-ok resp)
json
(throw json)))))
(.then (fn [resp-json]
(js/console.log "in then")
(js/console.log resp-json)
(js/console.log (-> resp-json .-description))))
(.catch (fn [resp-json]
(js/console.log "in catch")
(js/console.log resp-json)
(js/console.log (-> resp-json .-description))))))
(fetch-and-then "")
;; wait for output, and then
(fetch-and-then "")
The fetch API returns a promise and then threads it through a js promise chain. If the response is not ok
then it throws in the first then
with is caught by catch
hmm, i'm not sure what you mean. that doesn't answer my question as to why the second then
receives an object in istead of of a promise...
and the callback to then takes whatever the previous promise delivers. the first then takes the response and calls .json on it. the second takes the json from that first then
right. the first then returns (.json resp)
, which returns a JS object, so the second then receives that JS object.
likewise, i would expect the first then to throw (.json resp)
, a JS object, and that catch would receive that
(.then (fn [input] ouput))
the fn returns an object, but its nested inside of the then
which returns a promise
@UN0TDQ30T I believe your confusion may be because .json
does not as you say give you a js object but a promise: https://developer.mozilla.org/en-US/docs/Web/API/Body/json
If you throw it, you get the promise in the catch. If you return it from .then
, the next .then
is evaluated with the resolved value of the former promise from the returned .json
call is resolved
okay, this is starting to make sense now. thanks all for your patience and explanations!
How can I see what is in value of this map:
{:req #object[IncomingMessage [object Object]], :res #object[ServerResponse [object Object]]}
@d.ian.b probably easiest by developing with cljs-devtools and console logging that value
I can use this with node-repl?
Anyone could explain me why Nashorn was useful for CLJS, and why it is not anymore? (Sorry for the newbee question)
I can use this with node-repl?
@neo2551 Others can probably answer more authoritatively than I can, but I think the basic idea is that the Nashorn developers decided it wasn't worth pursuing. Probably they either consider it too far behind the state of the art of other JavaScript run time environments, and/or some combination of that and I believe I have heard that Graal will have its own JavaScript runtime, different than Nashorn, but more actively developed. Probably some developers consider that a better foundation for a modern JS implementation?