This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-03
Channels
- # announcements (4)
- # aws (13)
- # babashka (35)
- # beginners (162)
- # boot (8)
- # calva (5)
- # chlorine-clover (15)
- # cider (64)
- # clj-kondo (20)
- # cljs-dev (29)
- # clojars (6)
- # clojure (166)
- # clojure-europe (3)
- # clojure-finland (6)
- # clojure-france (8)
- # clojure-germany (3)
- # clojure-italy (3)
- # clojure-nl (7)
- # clojure-spec (49)
- # clojure-uk (83)
- # clojurescript (39)
- # clojurex (5)
- # core-typed (2)
- # cursive (3)
- # data-science (17)
- # datascript (3)
- # datomic (22)
- # exercism (5)
- # fulcro (3)
- # jobs-discuss (2)
- # joker (2)
- # kaocha (3)
- # malli (26)
- # off-topic (89)
- # pathom (10)
- # pedestal (14)
- # protorepl (14)
- # re-frame (23)
- # reitit (2)
- # shadow-cljs (27)
- # slack-help (10)
- # spacemacs (14)
- # tools-deps (10)
- # tree-sitter (3)
- # xtdb (19)
- # yada (2)
how to convert an input stream to a blob? I have the following code: (go (let [response (<! (http/get (str url "/run-segmentation"))) file-reader (js/FileReader.) ] (set! (.-onload file-reader) (fn [e] (let [data-url (-> e .-target .-result)] (prn "data-url is " data-url) ))) (.readAsDataURL file-reader (:body response)))) And I want to readAsDataURL the input stream in the body
you're running this in the browser right? What type of data is http/get actually returning?
like you're not be able to get an input-stream
as you would in JVM Clojure, as there is AFAIK no streams yet in browsers. So my guess is that you're getting either a string, buffer or blob directly there
Hello guys, i can't seem to get cljs-http to send the request how i want it. I want to send a GET request with an edn content-type, doing so from postman works just fine, but doing it through cljs-http comes off different in my api
When i use cljs-http params in my api come off as {}
i changed it to post request instead of get and it works just fine
i just can't seem to find a way with cljs-http to send a body
I'm fairly certain you only want to use content-type header when doing requests that normally have a body (so like POST, PUT and alike [even if technically you can send a body with a GET request, it's normally avoided]). Instead, take a look at the Accept
header for signal to the backend what content the client can use
@UJRDALZA5 nitpick but worth sharing anyways: GET can have a body, obviously a bad pattern as servers usually won't support it and no one expects that, but some backends, especially when they support large query parameters, also accept a GET with parameters for sending larger set of parameters. I think ElasticSearch is one of the more famous software that supports sending data in the body of a GET request
🙂 Conclusion last time I read the http spec is that while you can send body in a GET request, the server should ignore it so it's not that useful, but then again we have the real world not giving two cents about specs 😛
Yes GET does support sending a body, and you can do it through postman, But i guess cljs-http does not allow that. So i switched my endpoint to POST
I'm trying to use the cljs.analyzer.api
to search the namespaces of my project for keyword constants, but it's tripping up on the external JS dependencies of my CLJS dependencies (react & reagent in this case: No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source
).
I'm thinking I probably need to setup a compiler environment before calling analyze-file
on my sources, but I'm not entirely sure how that can be done (or if it's even the issue in the first place). Does anyone have experience running cljs.analyzer
on their own sources?
I also have figwheel-main up and running, so maybe I could reuse the compiler environment from their repl.
@ak407 what do you mean by external dependencies? might want to move this conversation over to #cljs-dev
I'm working with a third party JS lib, and a lot of the conversion of React components is tedious/hard to read. Is there a simple way to output (def formatted-name (adapt-react-class lib/FormattedName)
? Ideally, I'd just start from a list with "FormattedName"
@brandon149 I’m not sure what you mean - what do you want to use formatted-name
for?
I need to run def
so that I can use those third party react components as reagent components (ie. with hiccup syntax)
I want to export it from a ns
Ideally hiding the fact that they are react components rather than reagent components?
That is exactly right
I can do it pretty trivially for just 1, but I'd like to apply it to a whole list of components
well, heads up - it’s hard to ignore completely that things are not reagent components. sometimes it’s better to embrace the interop…
My primary concern is using adapt-react-class
to use them at all. I'd like to just have that all in one place
something like….
in my_app/some_lib.clj
(ns my-app.some-lib)
(defn camel->kebab
[sym]
,,,)
(defmacro gen-defs
[prefix component-names]
`(do
~@(for [component component-names]
`(def ~(camel->kebab component)
(reagent.core/adapt-react-class
~(symbol prefix component))))))
in my_app/some_lib.cljs
(ns my-app.some-lib
(:require
["some-lib" :as some-lib])
(:require-macros [my-app.some-lib :refer [gen-defs]))
(gen-defs
some-lib
[FormattedName])
I tried something similar (now exact, cause I like your api more) and what happens when I load the page is that the components aren't available for some reason
Those components don't show up until after the ns that has those definitions is live reloaded (I'm using shadow-cljs)
I'll try that. It's weird, I logged some values, and they're all undefined
until I save that file. It must be evaluating differently in those contexts, right?