Skip to content

Commit b0487bd

Browse files
committed
Notes on encapsulation
1 parent f9f20eb commit b0487bd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

rfcs/2024-05-21-ui-component-model.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ Context: converge on a default UI component model for LLM-generated UI.
2020
### Technical goals
2121

2222
- Components are **encapsulated**
23-
- A component may control its child tree, but not its siblings or parent
24-
- Components are **black boxes**, with inputs and outputs
23+
- A component may control its child tree, but not its siblings or parent
2524
- Components have **inputs**, and **output UI** and **events**
2625
- Are pure-ish functions of state (we may allow cheats for local component state ala hooks)
26+
- Components are **black boxes**
27+
- Components are decoupled and only communicate via input and output channels.
2728
- Component **inputs** and **outputs** are **statically-typed**
2829
- E.g. via TypeScript
2930
- Allows the runtime to enforce data policies on component
@@ -38,7 +39,7 @@ Context: converge on a default UI component model for LLM-generated UI.
3839
- Note: in something like the Elm App Architecture Pattern, Models, Views, and Update functions are “zippered” together, meaning components are “some assembly required”. This would fall short of this goal without some additional means of making an individual component free-standing.
3940
- Components are **composable**
4041
- Components can be combined together like lego to create larger components
41-
- Composition should involve plugging together component inputs, outputs, and events, and arranging a UI tree. It shouldn’t be more complicated than that.
42+
- Composing plugins should be as easy as plugging together component inputs, outputs, and events, and arranging a UI tree. It shouldn’t be more complicated than that.
4243
- Components can have **holes**, allowing you to slot in an arbitrary component of the right shape.
4344
- Inversion of control for templates.
4445
- The shape of the hole is determined by the data’s input and output types
@@ -47,10 +48,14 @@ Context: converge on a default UI component model for LLM-generated UI.
4748
- [passing down closures that evaluate to components](https://swiftwithmajid.com/2019/11/06/the-power-of-closures-in-swiftui/)
4849
- [overridable blocks](https://mustache.github.io/mustache.5.html#Blocks)
4950
- Components have **[high locality of behavior](https://github.com/gordonbrander/generative-ui-playbook?tab=readme-ov-file#llms-work-best-with-high-locality)**
51+
- Components are relatively **small**
52+
- LLMs will have higher accuracy generating small islands of interactivity vs whole apps
53+
- Small composable components are easier to understand and debug
5054
- UI **templates** are **pure functions of state**
5155
- Templates take inputs, and output a UI tree and events
5256
- Templates produce a UI tree that is easy for the runtime to analyze and sanitize (probably a VDOM, probably not raw DOM).
53-
- Components can be rendered on the web platform
57+
- Components are renderable to web
58+
- Other platforms may be supported in future, but web platform is primary
5459

5560
Soft goals:
5661

0 commit comments

Comments
 (0)