diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2022-05-23 19:31:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 19:31:31 +0100 |
commit | cb67e922d996077154dfdd05961071b2cc8cc7fc (patch) | |
tree | ade6c05f93a02a023e2f95c798cfa7ed912bfbc1 | |
parent | af7c2e44f3bb3e52cea363c4188a39fc1924931f (diff) | |
parent | bf8a9cac431370c5ce649ed240b37391d392b494 (diff) | |
download | lustre-cb67e922d996077154dfdd05961071b2cc8cc7fc.tar.gz lustre-cb67e922d996077154dfdd05961071b2cc8cc7fc.zip |
🔀 Merge pull request #1 from megapctr/patch-1
docs: fix the example so that it compiles
-rw-r--r-- | README.md | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -10,32 +10,36 @@ A framework for building create web apps – powered by Gleam and React! ```gleam import gleam/int import lustre -import lustre/element.{ button, div, p, text } -import lustre/event.{ dispatch, on_click } +import lustre/element.{button, div, p, text} +import lustre/event.{dispatch, on_click} +import lustre/cmd -pub fn main () { - let app = lustre.application(0, update, render) - lustre.start(app, "#app") +pub fn main() { + let app = lustre.application(#(0, cmd.none()), update, render) + lustre.start(app, "#app") } -type Action { - Incr - Decr +pub type Action { + Incr + Decr } -fn update (state, action) { - case action { - Incr -> state + 1 - Decr -> state - 1 - } +fn update(state, action) { + case action { + Incr -> #(state + 1, cmd.none()) + Decr -> #(state - 1, cmd.none()) + } } -fn render (state) { - div([], [ - button([ on_click(dispatch(Decr)) ], [ text("-") ]), - p([], [ text(int.to_string(state)) ]), - button([ on_click(dispatch(Incr)) ], [ text("+") ]) - ]) +fn render(state) { + div( + [], + [ + button([on_click(dispatch(Decr))], [text("-")]), + p([], [text(int.to_string(state))]), + button([on_click(dispatch(Incr))], [text("+")]), + ], + ) } ``` |