Skip to content

Commit d8e5f7c

Browse files
author
Ryan Miville
committed
formatting
1 parent bb5ed80 commit d8e5f7c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/todomvc.gleam

+14-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Filter {
4343
Completed
4444
}
4545

46-
fn init(_flags) -> #(Model, Effect(msg)) {
46+
fn init(_) -> #(Model, Effect(msg)) {
4747
#(Model(dict.new(), All, 0, "", ""), effect.none())
4848
}
4949

@@ -78,6 +78,7 @@ fn update(model: Model, msg: Msg) -> #(Model, Effect(Msg)) {
7878
let model = Model(..model, todos:, last_id:, new_todo_input: "")
7979
#(model, effect.none())
8080
}
81+
8182
UserBlurredExistingTodo(id) -> {
8283
let todos =
8384
dict.upsert(todos, id, fn(i) {
@@ -87,13 +88,16 @@ fn update(model: Model, msg: Msg) -> #(Model, Effect(Msg)) {
8788
let model = Model(..model, todos:, existing_todo_input: "")
8889
#(model, effect.none())
8990
}
91+
9092
UserClickedClearCompleted -> {
9193
let todos = dict.filter(todos, fn(_, item) { !item.completed })
9294
#(Model(..model, todos:), effect.none())
9395
}
96+
9497
UserClickedFilter(filter) -> {
9598
#(Model(..model, filter:), effect.none())
9699
}
100+
97101
UserClickedToggle(id, checked) -> {
98102
let todos =
99103
dict.upsert(todos, id, fn(i) {
@@ -103,17 +107,20 @@ fn update(model: Model, msg: Msg) -> #(Model, Effect(Msg)) {
103107
let model = Model(..model, todos:)
104108
#(model, effect.none())
105109
}
110+
106111
UserClickedToggleAll(checked) -> {
107112
let todos =
108113
dict.map_values(todos, fn(_, i) { Todo(..i, completed: checked) })
109114
let model = Model(..model, todos:)
110115
#(model, effect.none())
111116
}
117+
112118
UserDeletedTodo(id) -> {
113119
let todos = dict.delete(todos, id)
114120
let model = Model(..model, todos:)
115121
#(model, effect.none())
116122
}
123+
117124
UserDoubleClickedTodo(id, input) -> {
118125
let todos =
119126
dict.upsert(todos, id, fn(i) {
@@ -124,6 +131,7 @@ fn update(model: Model, msg: Msg) -> #(Model, Effect(Msg)) {
124131
let model = Model(..model, todos:, existing_todo_input: input)
125132
#(model, focus_edit_input())
126133
}
134+
127135
UserEditedTodo(id) -> {
128136
use <- bool.guard(existing_todo_input == "", #(model, delete_todo(id)))
129137

@@ -136,10 +144,12 @@ fn update(model: Model, msg: Msg) -> #(Model, Effect(Msg)) {
136144
let model = Model(..model, todos:)
137145
#(model, effect.none())
138146
}
147+
139148
UserUpdatedExistingInput(existing_todo_input) -> {
140149
let model = Model(..model, existing_todo_input:)
141150
#(model, effect.none())
142151
}
152+
143153
UserUpdatedNewInput(new_todo_input) -> {
144154
#(Model(..model, new_todo_input:), effect.none())
145155
}
@@ -168,7 +178,9 @@ fn header(model: Model) {
168178

169179
fn main_content(model: Model) {
170180
let visible_todos = case model.filter {
171-
All -> dict.values(model.todos) |> list.sort(compare)
181+
All ->
182+
dict.values(model.todos)
183+
|> list.sort(compare)
172184
Active ->
173185
dict.values(model.todos)
174186
|> list.filter(fn(i) { !i.completed })

0 commit comments

Comments
 (0)