From bf8a9cac431370c5ce649ed240b37391d392b494 Mon Sep 17 00:00:00 2001 From: Filip Figiel Date: Mon, 23 May 2022 13:07:37 +0200 Subject: docs: fix the example so that it compiles --- README.md | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index e1e167a..966f259 100644 --- a/README.md +++ b/README.md @@ -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("+")]), + ], + ) } ``` -- cgit v1.2.3