Fork me on GitHub

Hi. Back in 2016, in ClojureScript 1.9.293, some changes were made to prevent problems with checking protocol membership when using :advanced builds (See!topic/clojure/onmJ2uyQzC4 ). I'm not sure if these changes were expected to be a complete fix for the problems discussed in the mentioned thread, but I am experiencing them now with js->clj using cljs 1.10.339. There are some more details on an issue I filed against cljs-ajax: . Is this expected behavior, and I am supposed to avoid js->clj for external json data, or did just I stumble on to a cljs bug?


@schmandle the issue was fixed for normal protocols yes but not "fastpath" protocols like ISeq so you can run still into it if the JSON data contains a field with a number that "accidentally" has the bits set of some protocol. eg. {"ab":4} when cljs$lang$protocol_mask$partition.. was renamed to ab


just for log: I got the answer in the beginner channels.


js->clj is not safe for arbitrary json data


@thheller Right. I'll stick to using transit then. Thanks


A question: is it possible to upload files (FormData) via re-frame-http-fx? I know it wraps around cljs-ajax, but it seems to be using only the simpler "ajax-request" API, and that API doesn't seem to specify necessary keys.

{:http-xhrio {:method :post
              :uri (api/api "path/to/upload-endpoint")
              :body formdata-with-file
              ;;:format (ajax/transit-request-format)
              ;;:response-format (ajax/transit-response-format)
              :response-format (ajax/raw-response-format)
              :on-success [::success-handler]
              :on-failure [::fail-handler]}}
This is how my invocation looks like; what I get in response is "unrecognized request format: nil".


what I'm trying to achieve is essentially cljs-ajax's

(POST "/send-file" {:body form-data
                      :response-format (raw-response-format)})
but written as re-frame-http-fx


ok, RE my question about file upload - turns out it's a case of PEBKAC, and I didn't notice my file data was actually nil (due a parameter being eaten somewhere upstack), so nevermind 🙂

Digital Baboon11:10:22

Hey guys! I'm using reagent, and have the following code calling a component, but instead of returning an object, I'd like to return a string, how would I go about this?

Digital Baboon11:10:06

It's returning an object right now


@im defroute is a macro that apparently always returns a function

Digital Baboon11:10:28

@souenzzo ah so I can’t. Alright, I’ll figure another way out of this 😁. Thank you!


@im checkout bidi and others routing libraries

Digital Baboon11:10:08

How would I go about calling a function like (defn content-dispatch [name] (content-{name})) ?


I would probably do something like


(def dispatch-map
  {"foo" content-foo
   "bar" content-bar

(defn content-dispatch [name]
  (let [dispatch (get dispatch-map name)]


Though it probably wouldn’t come up that often since you can pass around functions as easily as you can pass around strings.


@im you could always set up a multimethod unless there are too many possible names for that to make sense, in which case yeah I'd do a hashmap lookup as in the above example