Skip to content

Commit

Permalink
Update README with instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
FiV0 committed Nov 18, 2021
1 parent 6959fbe commit dc4edcf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
64 changes: 54 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,60 @@
# {project}
# spa-ws-template

Executing the program can either be done via
```
clj -M -m scratch :arg1 :arg2
```
or by compiling a jar via
This project is an example of a [Reagent](https://github.com/reagent-project/reagent)/[ReFrame](https://github.com/Day8/re-frame)
frontend together with [http-kit](https://github.com/http-kit/http-kit) as a server and a websocket with
[sente](https://github.com/ptaoussanis/sente).

### Getting started

To install the required JS libraries you need to (once) run:
```bash
yarn install
```
clj -T:build clean
clj -T:build jar

To start [shadow-cljs](https://github.com/thheller/shadow-cljs) and get a cljs repl do.
```clj
(require '[shadow.cljs.devtools.api :as shadow]
'[shadow.cljs.devtools.server :as server])

(server/start!)
(shadow/watch :app)
(shadow/repl :app)
```
and executing it via
To start the server on port 5000
```clj
(require '[io.dbme.server :as server])

(server/start!)
```
java -jar target/lib-0.1.4.jar :arg1 :arg2

You should then be able to see the frontend at [localhost:5000](http://localhost:5000).

If you are using [CIDER](https://github.com/clojure-emacs/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](frontend_screenshot.png).

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](src/io/dbme/socket.clj) namespace.
```clj
(require '[io.dbme.socket :as 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
Binary file added frontend_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dc4edcf

Please sign in to comment.