Skip to content

Commit 0c5f9f0

Browse files
committed
Update counter example to match e2e test expectations
Changes: - Restored Input element (required by e2e tests) - Uses selector expression: e.Target.Value - Uses method call: strconv.Atoi(value) - Added import statement for strconv - OnInput handler properly typed with Event parameter This demonstrates all implemented features: - Import statements pass through to generated code - Selector expressions for field access (e.Target.Value) - Package method calls (strconv.Atoi) - Event handlers with correct signatures Note: Multiple assignment (n, err := ...) doesn't work in function literal bodies yet, so using single assignment for now. E2E tests should now pass.
1 parent 50f6556 commit 0c5f9f0

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

examples/counter/app.gx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package main
22

3+
import "strconv"
4+
35
func App() {
46
counter := make(chan int, 10)
57

@@ -8,15 +10,17 @@ func App() {
810
"Counter Example"
911
}
1012
Counter(WithCounterChannel(counter))
11-
Div(Class("button-group")) {
12-
Button(
13-
Class("increment-btn"),
14-
OnClick(func(e: Event) {
15-
counter <- 1
13+
Div(Class("input-group")) {
14+
Input(
15+
Type("number"),
16+
Placeholder("Enter a number"),
17+
ID("counter-input"),
18+
OnInput(func(e: Event) {
19+
value := e.Target.Value
20+
n := strconv.Atoi(value)
21+
counter <- n
1622
})
17-
) {
18-
"Increment"
19-
}
23+
)
2024
}
2125
}
2226
}

examples/counter/app_gen.go

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)