Skip to content

Commit 5c89716

Browse files
committed
Add app.gx as reference for intended syntax
This file documents the intended syntax for the App component, showing how it would be written in .gx format once the parser supports: - Type arguments in function calls (make(chan int, 10)) - Variable declarations in component bodies Currently this file is not parseable, so the component is manually written in app_gen.go. This serves as: 1. Documentation of the intended component design 2. A reference for future parser enhancements 3. A test case for when type arguments are supported The syntax shows the complete reactive pattern: - Creating a channel with make() - Wiring Input events to send channel values - Passing channel to child component - Child receives updates via channel listener
1 parent 3a7d18d commit 5c89716

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

examples/counter/app.gx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package main
2+
3+
// NOTE: This file is not currently parseable by the Guix parser because:
4+
// 1. make(chan int, 10) has a type argument which the parser doesn't support yet
5+
// 2. Function calls in the parser expect expression arguments, not type arguments
6+
//
7+
// For now, this component is manually written in app_gen.go
8+
// Future work will extend the parser to support type arguments in built-in functions
9+
10+
// This is the intended syntax for the App component:
11+
//
12+
// func App() {
13+
// counter := make(chan int, 10)
14+
//
15+
// Div(Class("app-container")) {
16+
// H1 {
17+
// "Counter Example"
18+
// }
19+
// Div(Class("input-group")) {
20+
// Input(
21+
// Type("number"),
22+
// Placeholder("Enter a number"),
23+
// ID("counter-input"),
24+
// OnInput(func(e: Event) {
25+
// value := e.Target.Value
26+
// n, err := strconv.Atoi(value)
27+
// if err == nil {
28+
// counter <- n
29+
// }
30+
// })
31+
// )
32+
// }
33+
// Counter(WithCounterChannel(counter))
34+
// }
35+
// }

0 commit comments

Comments
 (0)