diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-19 22:40:55 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-19 22:40:55 +0100 |
commit | 8d05b2dea4afc46a03dc12e26d7b37d45140eaf9 (patch) | |
tree | 37ab92610f2fb8290c208ebb4137ad194afbb7d2 /lib/test/examples/nested.gleam | |
parent | 9919bc2702c89168d1805eaa0db9e4baff091260 (diff) | |
download | lustre-8d05b2dea4afc46a03dc12e26d7b37d45140eaf9.tar.gz lustre-8d05b2dea4afc46a03dc12e26d7b37d45140eaf9.zip |
:sparkles: Allow starting args to be passed to an app's init function on start.
Diffstat (limited to 'lib/test/examples/nested.gleam')
-rw-r--r-- | lib/test/examples/nested.gleam | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/test/examples/nested.gleam b/lib/test/examples/nested.gleam index 47bb9d5..91c2da4 100644 --- a/lib/test/examples/nested.gleam +++ b/lib/test/examples/nested.gleam @@ -14,8 +14,8 @@ 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, render) - let assert Ok(_) = lustre.start(app, "[data-lustre-app]") + let app = lustre.simple(init, update, view) + let assert Ok(_) = lustre.start(app, "[data-lustre-app]", Nil) Nil } @@ -25,10 +25,10 @@ pub fn main() { type Model = Map(Int, counter.Model) -fn init() -> Model { +fn init(_) -> Model { use counters, id <- list.fold(list.range(1, 10), map.new()) - map.insert(counters, id, counter.init()) + map.insert(counters, id, counter.init(Nil)) } // UPDATE ---------------------------------------------------------------------- @@ -45,10 +45,10 @@ fn update(model: Model, msg: Msg) -> Model { // RENDER ---------------------------------------------------------------------- -fn render(model: Model) -> Element(Msg) { +fn view(model: Model) -> Element(Msg) { let counters = { use rest, id, counter <- map.fold(model, []) - let el = element.map(counter.render(counter), pair.new(id, _)) + let el = element.map(counter.view(counter), pair.new(id, _)) [el, ..rest] } |