Search code examples
angularjsclojure

Call a function in clojure website


I just started learning some Clojure and i have some general questions about it, since i can't find anything about it in google.

  • I will create a website with clojure. How can i call a function on the website via an a-Tag or a button? Is this even possible? If not, how can i react to user interactions?
  • is it possible to pass data through clj files? I have experiance with Angular JS. There, if I want to share data, I just store it in a global factory and later I can just access it. Is this also possible in clojure? I don't want to use angular or JS in this application.
  • how can i get data from an url: /myroute/myId (car/5). I want to get the ID 5.

I hope you can understand my questions. Thanks in advance


Solution

  • You can use Clojure to make a robust back end server. You can use a library such as compojure for routing. This enables you to transfer data via request and response maps. For the front end you can use Clojurescript (which unlike Clojure, runs on javascript). Clojurescript is not easy to set up until you are very comfortable with how projects are set up in Clojure.

    The libraries and plugins that I definitely recommend are:

    For Clojure (back end):

    • Ring
    • Compojure
    • clj-http or http-kit

    For ClojureScript

  • figwheel