Skip to content

Commit ad8ad40

Browse files
committed
Add example of fluent-style
1 parent d825e5c commit ad8ad40

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,29 @@ const cleanVdom = sanitize(vdom)
213213
render(dom, cleanVdom)
214214
```
215215

216+
## Fluent-style
217+
218+
```html
219+
const [count, setCount] = signal(0)
220+
221+
// Create a UI component
222+
const a = $('a')
223+
224+
// Get events as a stream
225+
a.clicks()
226+
.scan((state, event) => state + 1, 0)
227+
.sink(setCount)
228+
229+
// Method chaining to set properties, children, etc
230+
a.text(count => `the count is ${count}`, count)
231+
232+
return a
233+
```
234+
235+
Prior art:
236+
237+
- [D3.js](https://d3js.org)
238+
216239
## Open questions
217240

218241
## Prior art

0 commit comments

Comments
 (0)