Skip to content
generated from FiV0/clj-template

Single page application with http-kit, sente and shadow in the box.

Notifications You must be signed in to change notification settings

FiV0/spa-ws-template

Repository files navigation

spa-ws-template

This project is an example of a Reagent/ReFrame frontend together with http-kit as a server and a websocket with sente.

Getting started

To install the required JS libraries you need to (once) run:

yarn install

To start shadow-cljs and get a cljs repl do.

(require '[shadow.cljs.devtools.api :as shadow]
         '[shadow.cljs.devtools.server :as server])

(server/start!)
(shadow/watch :app)
(shadow/repl :app)

To start the server on port 5000

(require '[io.dbme.server :as server])

(server/start!)

You should then be able to see the frontend at localhost:5000.

If you are using CIDER you can also just jack-in via cider-jack-in-clj&cljs.

Sending stuff over the websocket.

The frontend then should look something like

frontend.

Once you connect, you should see a log message in your clj repl telling you that a connection has been established.

Now you are able to send stuff over the websocket connection. You can add some clojure data in the send field, for example {:hello :world}. Once you hit send you should once again see a log message with the data in your server repl.

For sending stuff from server to client you can look at the socket namespace.

(require '[io.dbme.socket :as socket])

(socket/send-data {:some-new-data true})

The data you send is then displayed above the send field in the frontend.

Happy hacking!

License

MIT Licence

About

Single page application with http-kit, sente and shadow in the box.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published