Fork me on GitHub

is <p! blocking in clojurescript?


Does it wait for the promise to resolve before evaluating the next expression?


It does, but it's not blocking. It parks instead of blocking.


what’s the difference between parking and blocking?


(<p! (some-promise))
(prn (+ 7 7))
does prn wait for the promise to resolve?


Blocking blocks - there's no more execution. Well, maybe in other threads on other platforms, but JS doesn't have them. Parking doesn't block - it allows for the execution to continue elsewhere. The second line of code above won't be executed till the promise is resolved, but some other code outside of that go block might be executed.


In other words, <p! blocks the current go block.


I asked this over on #cljsrn on the off chance this was sth about RN JS, but no ideas yet: Got a dummy interop Q here: what on Earth is #object[String]? Using the cljs-http example:                   (http/get ""                                       {:with-credentials? false                                        :query-params      {"since" 135}}) I pull the users as suggested with: (map :login (:body response)) Looks great, except when I offer the first as the title of a Button (have not figured out Text yet, of all things), ReactNative complains: "Invariant Violation: The title prop of a Button must be a string" So I print out the type and sure enough it is #object[String]. js->clj does not help. str works, but I do not get why: (type (str etc)) also returns #object[String]! Weirdly, if I (map str (map :login etc)) as soon as I get the response, I still have to call str when passing the first username as the title! So...what on Earth is #object[String]?! The Google is silent, tho with tons of hits on translating key-value kinda objects. I started thinking it might be how a JSON object might be presented in the reader, but got nowhere with that idea. btw, I can use goog.object to get all the keys: length, 1,2,3... 🙂 object[String] aside, I am exploring having cljs-http convert the response to a clojure map (if there is such a feature). But that would be an ugly way out. I had the same thought about having goog.object parse the response before I got down to an individual object[String]: ugly.


May be a RN thing in the end? I tried this with ClojureScript in the browser and get normal strings :thinking_face:


Now I'm kind of confused about your statement of: > I am exploring having cljs-http convert the response to a clojure map (if there is such a feature). Because it seems thats what I get back from cljs-http when doing this request in the first place :thinking_face:


Yeah, @U6JS7B99S, it is tough looking at print output and understanding what is going on. Turns out the map values are all ValSeq's: Looks like I need to call the toString method on one to get a Clojure string. googles Clojure records


OK, haha, this was the other direction of interop: converting CLJ ValSeq to JS to make RN happy, and even funnier, str is exactly how to convert a ValSeq to a string RN will like.


Maybe you've already found this, but I think this might be a someone instantiating a String vs using a string literal, which has some differences


I think I had to use cljs.reader/read-string for a similar issue. I think I also added :type :text to the keys in the http/get map... Did you resolve your issue?


Yes, @U3ES97LAC, thanks. I guess cljs-http is creating the ValSeq strings. Anyway. all I needed was a way to pass the string value to RN as the title of the button, and the Helix doc makes clear that I have to take care of that, not Helix. The funny thing is I had succeeded with (str my-val-seq) early on but thought that was a hack, a failure to interop. 🙂 It was, but not what I thought: converting from JS. With str I converted /to/ a string JS could handle, and str (via toString) is the preferred method for converting ValSeq to a str. It just took me six hours to figure that out. 🙂


😅 i think it took me a couple months to find out about cljs.reader/read-string so you're doing great at just a quarter of a day.


haha, you know, I tried read-string, that did not work for me. I think right about there is where I pulled down the cljs-http source and tracked down ValSeq. That is when I realized I was dealing with a reverse interop issue!