Skip to content

Commit

Permalink
docs: start README
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Hivert <[email protected]>
  • Loading branch information
ghivert committed Apr 17, 2024
1 parent 724eaf4 commit 4f440f2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.ez
/build
erl_crash.dump
.DS_Store
Thumbs.db
*~
53 changes: 43 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,58 @@
# Tardis

[![Package Version](https://img.shields.io/hexpm/v/tardis)](https://hex.pm/packages/tardis)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/tardis/)
<!-- [![Package Version](https://img.shields.io/hexpm/v/tardis)](https://hex.pm/packages/tardis)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/tardis/) -->

Every good frontend framework should have a good debugger. Tardis tries to fill
this gap with [Lustre](https://hexdocs.pm/lustre). Because of the immutable nature and the management of side-effects of lustre, it's possible to implement a debugger able to register everything that happened in the app and that can rewind the time in order to display the state of your app, at any point in time! Tardis is a time-traveller debugger, made to interact with multiple lustre applications and components on one page, with the simplest setup possible yet!

## Demo

![Demo video](assets/demo.mp4)

## Quickstart Guide

First, add tardis to your gleam project.

```sh
gleam add tardis
```

Then, setup the package.

```gleam
import gleam/int
import lustre
import lustre/element/html
import lustre/event
import tardis
pub fn main() {
// TODO: An example of the project in use
let main = tardis.single("main")
lustre.application(init, update, view)
|> tardis.wrap(main)
|> lustre.start("#app", Nil)
|> tardis.activate(main)
}
```
Further documentation can be found at <https://hexdocs.pm/tardis>.
fn init(_) {
0
}
## Development
fn update(model, msg) {
case msg {
Incr -> model + 1
Decr -> model - 1
}
}
```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
fn view(model) {
let count = int.to_string(model)
html.div([], [
html.button([event.on_click(Incr)], [html.text(" + ")]),
html.p([], [html.text(count)]),
html.button([event.on_click(Decr)], [html.text(" - ")])
])
}
```
Binary file added assets/demo.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion src/tardis.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn setup() {
|> result.map(fn(dispatch) { Instance(dispatch) })
}

pub fn singleton(name: String) {
pub fn single(name: String) {
setup()
|> result.map(application(_, name))
}
Expand Down

0 comments on commit 4f440f2

Please sign in to comment.