Fork me on GitHub

Has anyone ever managed to set the current line / column / file path of an evaluation from within a ClojureScript REPL? Edit: Maybe self hosting will do the trick? Just worried that'll mean it's not really the same. I presume there's subtle differences between JVM and self host ClojureScript.


I'm building a simple web app. In order to call a web service, I'm trying to include cljs-http. I've added the appropriate :require and :require-macros (according to the cljs-http github page) for cljs-http and core.async to my .cljs file, and the reference to [cljs-http "0.1.46"] in my project.clj file, but figwheel still gives me a 'No such namespace: cljs-http.client, could not locate cljs_http/client.cljs, cljs_http/client.cljc, or JavaScript source providing "cljs-http.client"' error. Any idea what gives?


I feel like I'm missing something obvious. My Reagent component is showing up in the browser with an extra 0s transition timing which breaks the transition. Any idea why?


@ben735 the extra 0s is the transition delay it should not break anything?


div {
    transition: <property> <duration> <timing-function> <delay>;


oh, I see you're right - I must be doing something else wrong, thanks!


I've modified my ns declaration to be this:(ns (:require-macros [cljs.core.async.macros :refer [go]]) (:require [reagent.core :as r] [cljs.core.async :refer [<!]] [cljs-http :as http]) )


@thheller ah I see now, I was assuming that changes would animate when figwheel is reloaded, but that's not the case - thanks for the pointer


but figwheel still can't find cljs-http. Any idea why it can't find this namespace (or the recommended cljs-http/client that also doesn't seem to work)


@fadrian it should be [cljs-http.client :as http]


Yeah. That was what I meant when I typed cljs-http/client. Fumbly fingers. In any case, the cljs is not finding this package either. Could there be something in my project setup that's causing cljs-http not to be found? (defproject cql-viewer "0.0.1" :description "A viewer for CQL interpreter output." :dependencies [[org.clojure/clojure "1.9.0"] [binaryage/devtools "0.9.4"] [org.clojure/clojurescript "1.10.238" :scope "provided"] [reagent "0.7.0"] [cljs-http "0.1.46"] ] :source-paths ["src/cljs"] :plugins [[lein-figwheel "0.5.16"] [lein-cljsbuild "1.1.7" :exclusions [[org.clojure/clojure]]]] :cljsbuild {:builds [{:id "dev" :source-paths ["src/cljs"] :figwheel {:on-jsload "cql-viewer.core/on-js-reload" :open-urls ["http://localhost:3449/index.html"]} :compiler {:main cql-viewer.core :asset-path "js/compiled/out" :output-to "resources/public/js/compiled/cql-viewer.js" :output-dir "resources/public/js/compiled/out" :source-map-timestamp true}}]} :figwheel {:css-dirs ["resources/public/css"]} :profiles {:dev {:dependencies [[binaryage/devtools "0.9.9"] [figwheel-sidecar "0.5.16"] [cider/piggieback "0.3.1"]] :source-paths ["dev"] :clean-targets ^{:protect false} ["resources/public/js/compiled"]}})


looks fine. did you restart the process after adding the dep?


Yes. I've been getting this error since yesterday evening when I tried to add the web service. I've cut and pasted directly from the github page for my setup and I'm not even calling any code from the packages yet - it just can't find the package.


I tried adding http-ajax and got a similar error. I'm beginning to think I'm cursed by the gods of http.


make sure you are restarting the correct process and stuff


maybe you are in a different directory or some process is still running in the background


Lein's sitting in the project directory. I've been thinking it might be something in my lein configuration. Any idea where that's stored?


in your project.clj


Are the repo directories hardwired? Because I swear I've seen a config file holding them (but I might be thinking of my emacs config).


I'm going to shut the whole shebang down and see if a restart does anything.


cljs-http README has this: (:require [cljs-http.client :as http]


Well that was aggravating. I had to shut down lein and restart it. Obvious and annoying in retrospect.


It's working now.


I think if you change deps lein figwheel doesn’t pick that up.


I had the same problem with lein test-refresh.

Chris Swanson15:06:47

hey has anyone recently gotten a clojurescript expo project running ? i tried the lein new expo template but the sdk is too old, and i couldn't figure out which versions of what to upgrade to in order to get it all compatible again

Chris Swanson15:06:18

if so' i'd be eternally grateful for your build config , save me hours...


I think I saw somethings a while back on github regarding this, but not 100% sure.


hey @chrisjswanson just saw your message in expo - you should definitely join the #cljsrn channel too. We have expo + cljs running, but I'm just going home for the day now, you're right there's a lot of things to figure out in order to get everything up to date, We've ended up making some quite significant changes to the whole thing, hopefully will contribute back at some point, but in the mean time can answer Qs


You might wanna try shadow-cljs and expo, too, I think I'd be tempted by that if I was starting from scratch today


I have a map:{"C" {"name" "C", "type" "Library", "evaluated" false, "value" nil, "isConst" false, …} , "E" {"name" "E", "type" "Library", "evaluated" false, "value" nil, "isConst" false, …} , "D" {"name" "D", "type" "Library", "evaluated" false, "value" nil, "isConst" false, …} }


I'm storing it in an atom @processed-cql and trying to add it to a web page with the hiccup [:p (str @processed-cql)]. However, the hiccup prints [Object object]. How can I get the map to display


I'm assuming it has something to do with the JS toString() operator, but I am a newbie at Clojurescript.


Is it a JavaScript map? Or. ClojureScript one?


(str {:a 12})
"{:a 12}"
(str #js {:a 12})
"[object Object]"


The map was originally JSON coming as a string from a web server. I converted it to a JS map using JSON.parse and then converted it to a Clojurescript one using js->clj as shown in the js->clj documentation. I've logged and checked all of the intermediate data from the conversion and it looks good. The final map is a Clojurescript map.


If so, you want to wrap it in a call to js->clj


(str (js->clj #js {:a 12}))
"{\"a\" 12}"


You actually don't need to call str if using hiccup


I've done that. Here's my code that makes the map: (go (let [response (<! (http/get url {:with-credentials? false})) b (:body response) _ (js/console.log b) json (.parse js/JSON b) _ (js/console.log json) m (js->clj json) _ (js/console.log m) ] m))


So, what you're facing is just typical JavaScript. Objects in JavaScript can't be printed out natively. You need to serialize them to a string to do so. You can use stringify on JSON (.stringify js/JSON #js {:a 12}) if you want.

Roman Liutikov17:06:38

how do you put it into hiccup then?

Roman Liutikov17:06:56

go loop is async, you can’t just return a value from it afaik


But, ClojureScript data-structures natively support being serialized as EDN. So converting to a clj data-structure also works. Which you can do with js->clj


Which is was what I was doing.


Oh, right. Okay, so it might be a different issue.


Ya, could be your Object is actually a goroutine


That may be.

Roman Liutikov17:06:47

@fadrian if you want to take return value out of go “process” you have to use a callback


Which also prints as Object in ClojureScript

Roman Liutikov17:06:26

(take! chan callback-render-hiccup)


Can you try calling type on your object?


Gah... That was it. I just read the documentation a bit more closely. I'll do some quick brushing up on core.async and hopefully I can get around this issue.


If you see cljs.core.async.impl.channels/ManyToManyChannel, then @roman01la is probably right about your issue

Roman Liutikov17:06:18

@fadrian One suggestion is to drop core.async if you are not dealing with complex async flows

👍 12
Roman Liutikov17:06:46

it generates lots of code and also tricks you into thinking stuff is executed synchrounously

Roman Liutikov17:06:05

promises are generally enough

Roman Liutikov17:06:45

(-> (js/fetch url) (.then #(.json %)) (.then #(js->clj %)))

Chris Swanson17:06:07

@danieleneal thanks ! I'll definitely join and catch up soon. have a good evening


Also, it was designed first for Clojure, where you can do a synchronous blocking take for that kind of single value use case. But in ClojureScript, you can't. So it make more sense if you're going to be producing a stream. Like say you were grabbing responses and wanted to process them as they are received.


"But in ClojureScript, you can't." Not technically, but practically, for now.


Hum.. I'm now intrigued


Well, now we've got js/Atomics and js/SharedArrayBuffers, which brings genuine blocking to webworker contexts


So, on that, we could feasibly write a genuine blocking take


And if you're only passing around typed arrays, which may be the case for some high performance application, it's a pretty low-overhead thing. Unfortunately, structures not already backed by typed arrays will still need to be serialized between worker contexts.


The future is long though, and it's not hard to imagine a lot of things getting converted to being backed by typed arrays, so they can be freely shared between js/wasm isolates


Hum.. I'm too out of touch with JavaScript and browser contexts to keep track of all these changes 😋


I don't even know what worker contexts are, did JS in browser now has support for threads?


I'll try that, roman01la. It seems pretty simple. didibus - this is just a debugging jig for a thing I'm writing. It would probably never need high enough performance to stream anything, so his solution is better for my needs. What I am writing will need something like core.async in its implementation, but then I first have the fun of shoehorning clojurescript into a standard node.js server environment, with things like express and webpack and many clojurescript/tool interactions that will make my progress halting. So it goes in the modern world of programming.

Roman Liutikov17:06:13

@fadrian for nodejs you'd probably want to look at Macchiato


Will do that. I think I have it going now. Thanks for the pointers.


hello guys Im looking for a simple FE framework that has some integrated mechanism for validating forms with spec.. is there such thing or should I do it manually ?