Thursday, January 19, 2023

Full-Stack Development

I'm building the guestbook web application by following the book Web Development with Clojure which is a wonderful book. However, I do get thrown off now and again as I read the code. I think I get it... and I explain it to myself but I'm not certain. It could be me hand-waving things away.

So I've been reading about debugging in Clojure, namely by watching/reading the following resources:


and I thought why not apply this to the guestbook app? So I can validate what I'm reading. Is that data structure holding what I think it's holding?

Till now, I've been launching the guestbook app:
  1. Server
    1. lein repl in a terminal OR
    2. Server configuration in VS Code/Calva
  2. Shadow-CLJS
    1. npx shadow-cljs watch app in a terminal
But I wanted to be able to be do everything in VSCode! 

After scouring various docs on the Calva site, I came across the following:
https://calva.io/luminus/ which has a video on how to create an app from scratch that is full-stack and uses shadow-cljs. BINGO! I then basically (painstakingly) went through the startup configurations of this demo app vs. the guestbook app to figure out what the difference was. The demo app could launch both the Server and CLJS and be able to REPL into both. I could only REPL into the server.

Somehow I stumbled onto settings.json which is part of VS Code and BAM, I saw how the demo app had a Server + Client config which I didn't have. This included a launchBuild and a command to start the server. This is exactly what I was missing in the guestbook app. These are actually called Connect Sequences. And after I copied it over to guestbook app, I was able to launch both Server + Client in one VS Code instance!

I also came across this goody on how the REPL works: https://blog.agical.se/en/posts/shadow-cljs-clojure-cljurescript-calva-nrepl-basics/ which I need to delve into.

But I also discovered the following cool resources as well that are on my list now to explore more:

Next Steps:
  1. Following the VSCode Calva tutorial, Welcome to Clojure, there are some instructions on how to use the Clojure debugger. I tried that with a piece of CLJS code to see if it would break when I hit the webpage, but I got a weird error. It does work with Clojure code though!
  2. Try out Tap
  3. Try out Reveal

No comments:

Post a Comment

Clojurescript with Reveal & VSCode

So my next foray was into getting Reveal to work with Clojurescript ( specifically Shadow-CLJS)  and VSCode and Leiningen. After a number of...