Skip to content

Instantly share code, notes, and snippets.

View atdiar's full-sized avatar

Awad Diar atdiar

View GitHub Profile
@atdiar
atdiar / stableid.md
Last active June 28, 2023 09:14
runtime: allow setting stable IDs for function types so that their methods can have access to per instance state

I have the following implementation for the Document Object Model API in Go (simplified example):

type Document struct{
    *ui.Element
    
    // list of constructors
    Body bodyConstructor
    Head headConstructor
    Div divConstructor
@atdiar
atdiar / full_expansion.go
Last active June 9, 2022 13:45
Flavors of declarative UIs
ui.New(doc.NewDocument("Todo-App"),
Children(
E(doc.NewSection("todoapp", "todoapp"),
Ref(&AppSection),
CSS("todoapp"),
Children(
E(doc.NewHeader("header", "header"),
CSS("header"),
Children(
E(doc.NewH1("todo", "apptitle").SetText("Todo")),
@atdiar
atdiar / direct-children-list.go
Last active June 8, 2022 20:37
declarative UI w? signature change
ui.New(
doc.NewDocument("Todo-App"),
NoModifier,
E(doc.NewSection("Appsection","todoapp"),
NoModifier,
E(doc.NewHeader("mainheader","header"),
NoModifier,
E(doc.NewH1("todo", "apptitle").SetText("Todo"), NoModifier),
E(NewTodoInput("todo", "new-todo"), NoModifier),
),
@atdiar
atdiar / declarative-nocss.go
Last active July 13, 2022 23:06
Comparing declarative UIs
ui.New(
doc.NewDocument("Todo-App"),
Children(
E(doc.NewSection("Appsection","todoapp"),
Children(
E(doc.NewHeader("mainheader","header"),
Children(
E(doc.NewH1("todo", "apptitle").SetText("Todo")),
E(NewTodoInput("todo", "new-todo")),
),