diff --git a/.gitignore b/.gitignore index 599be4e..c42a486 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.ez /build erl_crash.dump +.DS_Store +Thumbs.db +*~ diff --git a/README.md b/README.md index 0a812c5..f4192b2 100644 --- a/README.md +++ b/README.md @@ -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/) + + +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 . +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(" - ")]) + ]) +} ``` diff --git a/assets/demo.mp4 b/assets/demo.mp4 new file mode 100644 index 0000000..6707193 Binary files /dev/null and b/assets/demo.mp4 differ diff --git a/src/tardis.gleam b/src/tardis.gleam index e155707..aef3228 100644 --- a/src/tardis.gleam +++ b/src/tardis.gleam @@ -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)) }