aboutsummaryrefslogtreecommitdiff
path: root/examples/counter.gleam
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2023-12-22 01:37:39 +0000
committerHayleigh Thompson <me@hayleigh.dev>2023-12-22 11:01:21 +0000
commitff3a5e7ce450f1007ae39a47f4e1b431da04a23d (patch)
treee355b8c8cbc5c662b8f700360672d43ae1dce519 /examples/counter.gleam
parentec7b40fc801e5f5af372f7b0b6524ee0bfcf8d3c (diff)
downloadlustre-ff3a5e7ce450f1007ae39a47f4e1b431da04a23d.tar.gz
lustre-ff3a5e7ce450f1007ae39a47f4e1b431da04a23d.zip
:recycle: Refactor example apps to use lustre/try instead of vite.
Diffstat (limited to 'examples/counter.gleam')
-rw-r--r--examples/counter.gleam53
1 files changed, 0 insertions, 53 deletions
diff --git a/examples/counter.gleam b/examples/counter.gleam
deleted file mode 100644
index 37af39a..0000000
--- a/examples/counter.gleam
+++ /dev/null
@@ -1,53 +0,0 @@
-// IMPORTS ---------------------------------------------------------------------
-
-import gleam/int
-import lustre
-import lustre/element.{type Element, text}
-import lustre/element/html.{button, div, p}
-import lustre/event
-
-// MAIN ------------------------------------------------------------------------
-
-pub fn main() {
- // A `simple` lustre application doesn't produce `Effect`s. These are best to
- // start with if you're just getting started with lustre or you know you don't
- // need the runtime to manage any side effects.
- let app = lustre.simple(init, update, view)
- let assert Ok(_) = lustre.start(app, "[data-lustre-app]", Nil)
-}
-
-// MODEL -----------------------------------------------------------------------
-
-pub type Model =
- Int
-
-pub fn init(_) -> Model {
- 0
-}
-
-// UPDATE ----------------------------------------------------------------------
-
-pub opaque type Msg {
- Incr
- Decr
- Reset
-}
-
-pub fn update(model: Model, msg: Msg) -> Model {
- case msg {
- Incr -> model + 1
- Decr -> model - 1
- Reset -> 0
- }
-}
-
-// VIEW ------------------------------------------------------------------------
-
-pub fn view(model: Model) -> Element(Msg) {
- div([], [
- button([event.on_click(Incr)], [text("+")]),
- button([event.on_click(Decr)], [text("-")]),
- button([event.on_click(Reset)], [text("Reset")]),
- p([], [text(int.to_string(model))]),
- ])
-}