This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-02
Channels
- # announcements (2)
- # babashka (16)
- # beginners (48)
- # biff (5)
- # calva (21)
- # cider (9)
- # clerk (24)
- # clj-kondo (43)
- # clj-otel (3)
- # clj-yaml (44)
- # cljdoc (13)
- # cljs-dev (2)
- # cljsrn (7)
- # clojure (39)
- # clojure-dev (21)
- # clojure-europe (18)
- # clojure-hamburg (1)
- # clojure-losangeles (1)
- # clojure-norway (24)
- # clojure-sweden (4)
- # core-typed (3)
- # cursive (7)
- # data-science (10)
- # datalevin (7)
- # datomic (49)
- # emacs (7)
- # events (2)
- # graalvm (7)
- # hyperfiddle (56)
- # integrant (10)
- # jobs-discuss (29)
- # leiningen (27)
- # lsp (12)
- # malli (3)
- # off-topic (13)
- # polylith (18)
- # reagent (13)
- # sci (49)
- # shadow-cljs (94)
- # sql (3)
- # squint (2)
- # vscode (5)
- # xtdb (17)
I have run into the following error after starting a Krell project from the repo:
Could not locate reagent/react_native__init.class, reagent/react_native.clj or reagent/react_native.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I am unable to resolve this error and have spent a lot of time trying to. I am getting quite frustrated with the dev experience of setting up Clojure projects 😞can you list screenshot of your file structure? on a side note: setting up projects in any new language is always a pain (for me at least). I view as a challenge because it forces to understand how different pieces in the project work together
Clojure appears difficult on another level in this category - there are so many files (why do I have Ruby files???). Elm is where I came from and it was extremely simple. Here is the screenshot
can I see inside src and folders below src
I was hoping you missed a dash in a file name 😬 we need to dig deeper. my next step would to look at deps.edn and the command you ran. Also, not sure if this would be relevant but what os are you using?
{:main thirdplace_krell.core
:output-to "target/main.js"
:output-dir "target"
:language-out :es5}
appreciate the help! I took a bet on Cljs over straight up RN as I was hoping it would make me more productive and I would enjoy developing more, but now weeks later after learning cljs and days of trying to bootstrap a project I am wondering if it was a waste and I should just do a standard TS/RN repo
are you sure that was your deps.edn file?
sorry, I gave you my build.edn. Here's the deps.edn
{:deps {io.vouch/krell {:git/url ""
:sha "08f2bfea96aa48feb8511851e37f5948453986e5"}
io.vouch/reagent-react-native {:git/url ""
:sha "0fe1c600c9b81180f76b94ef6004c2f85e7d4aa0"}
reagent/reagent {:mvn/version "0.10.0"
:exclusions [cljsjs/react cljsjs/react-dom]}}}
i am looking at this https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial Have you tried removing language-out key in your build file?
ended up deleting the target folder and re-compiling the project and it worked, but still working on getting JS files to import. If I can't get it done within the next 20 minutes I'll probably just use RN vanilla, this isn't worth it for me anymore
I keep getting ; TypeError: Cannot read property 'pprint' of undefined
after jacking-in my editor (VSCode) and importing a JavaScript file using js/require in a Krell setup. This applies to all forms and cannot be removed unless I redo the jack-in process
This will completely destroy the current repl session and requires that it be restarted
Current error message:
ERROR Could not evaluate form: try{var sb__2458__auto___7133 = (new goog.string.StringBuffer());
var sbw__2459__auto___7134 = (new cljs.core.StringBufferWriter(sb__2458__auto___7133));
var form__2460__auto___7135 = (function (){var ret__2462__auto__ = require("../src/js/SlidingPanel.js");
(cljs.core._STAR_3 = cljs.core._STAR_2);
(cljs.core._STAR_2 = cljs.core._STAR_1);
(cljs.core._STAR_1 = ret__2462__auto__);
return ret__2462__auto__;
})();
cljs.pprint.pprint.call(null,form__2460__auto___7135,sbw__2459__auto___7134);
cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb__2458__auto___7133);
}catch (e7132){var e__2463__auto___7136 = e7132;
(cljs.core._STAR_e = e__2463__auto___7136);
throw e__2463__auto___7136;
} [TypeError: Cannot read property 'pprint' of undefined]
Hey all, I have a question about web development. I have learned to create a front-end with ClojureScript and Tailwindcss, I learned to make a backend with Clojure and connect it to a database, also learned how to make a jetty
server and have it receive requests with ring
.
Now my question is how do I link those in the following fashion, the front-end makes a request to the back-end and receives a response that it can consume as Clojure(Script) data. For example my back-end function returns the following
[1 2 3]
and the following for my router
(def app
(ring/ring-handler
(ring/router
["/"
[":symbol/" get-data]])))
This is my handler
(defn get-data [req]
(let [symbol-name (get-in req [:path-params :symbol])]
(r/response (db/back-end-func symbol-name)))))
The response returns 123
and not the vector. What am I missing? What do I need to learn?
From my search I found the following:
• https://www.reddit.com/r/Clojure/comments/y4op7q/how_do_i_send_data_between_front_end_and_back_end/ which leads to http-kit
which seems popular according to https://www.reddit.com/r/Clojure/comments/x38puy/which_library_you_are_using_for_web_server_why/just a few things, when you say response is returning 123 I am guessing this is client side as (r/response (db/back-end-func symbol-name))
should be returning a map with a :body key, if its client side I would look at the headers and hazard at a guess you need to parse your vector to a json string or edn string to send it to the client where you can read it in your client side application.
When I evaluate (r/response (db/back-end-func symbol-name))
I get {:status 200, :headers {}, :body (1 2 3)}
I was wrong about the return being a vector, it looks like it's a lazy sequence, does that affect it? I tried wrapping my return with a (vec)
now my map is {:status 200, :headers {}, :body [1 2 3]}
and when I check the response in a browser I see no value.
When you say parse it as a edn or json string is it something similar to (str (to-json my-vector))
?
yeah basically you can't send raw data structures over the wire so usually you translate to json or edn
Understood, I did manage to get a response that is a string, now time to request it inside my cljs frontend. Any direction before I go search?
you can use something like this https://github.com/JulianBirch/cljs-ajax on the client side
you can also look into ring middleware to do the conversions, I use ring reitit swagger I think the conversion is done by the coersion middleware if i remember
Thank you, this gives me some direction to look, I am using reitit.ring
here so I can look into those. For now I'll try the simple approach of converting before I send then dive deeper into it, thanks again!
if your using reitit then you can import this [reitit.ring.middleware.muuntaja :as muuntaja]
Yep I'm new to web development in addition to being new to CLJS, there's a lot to learn but that's where the fun is
I reached something... I was able to get the back-end to send a JSON and I was able to check that in the browser. Now to use that in the front-end I have the following
(fn []
(p/let [response (js/fetch " ")
value (.json response)
data (js->clj value :keywordize-keys true)]
(swap! stock-data (fn [] data))))
Where data
is the data in ClojureScript form, I'm running (swap!)
that affects a global (r/atom)
.