Coder Social home page Coder Social logo

holygrail's Introduction

Holy grail demo - forked for some experimenting

What is it?

This demonstrates the “holy grail” workflow for web development the way I envision it: a restartable back-end in the REPL + a hot-reloadable front-end in the browser.

Demo

Make sure boot-clj is installed. This is the awesome build tool that makes this worflow possible.

Clone this repo, cd into it and start the development pipeline build.

$ git clone [email protected]:danielsz/holygrail.git
$ cd holygrail
$ boot dev

This starts the build pipeline. Pay attention to the line that says:

nREPL server started on port 49722 on host 127.0.0.1 - nrepl://127.0.0.1:49722

Launch your favorite editor, and connect to the headless REPL (M-x cider-connect in Emacs works great). The N Type:

(go)

In the browser, go to http://localhost:3000

You will see a simple web app that doesn’t do much, but the point is the workflow. In other words, the possibilities to develop both APIs and client-side functionality in the most comfortable way. Let’s demonstrate this.

Open the file src/clj/real_time/handler.clj. Let’s add a route:

(defroutes app-routes
  (GET "/" [] (-> (resp/resource-response "index.html")
                     (resp/content-type "text/html")))
  (GET "/foo" [] (str "<h1>Hello, world</h1>")) ;; let’s add this
  (route/not-found "Not Found"))

Now save the file, go to your REPL, and type:

(reset)

In the browser, type http://localhost:3000/foo. You’ve just worked on the backend, made a change, and restarted it from the REPL. How cool is that?

Now let’s do a change client-side. Open src/cljs/real_time/core.cljs and on line 26 change the string for Value from “submit” to “send”. Save the file. The change is reflected automatically in the browser. How cool is that?

Do you feel the creative juices flow? Aren’t you all set to dive in the zone for endless hours of sheer creative output?!

holygrail's People

Contributors

danielsz avatar daslu avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.