Skip to content

Commit 11ea24c

Browse files
committed
docs: update README
1 parent 8ef9248 commit 11ea24c

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ Or, in Deno,
3232
deno add @kt3k/cell
3333
```
3434

35-
## Hello world: How to use `on` helper
35+
## Hello world: How to use `on`
3636

37-
The below is an example of `cell` component. A `cell` component is a function of
37+
The below is an example of a cell component. A cell component is a function of
3838
the type `(ctx: Context) => string | undefined`.
3939

40-
`Context` includes many handy helpers for implementing UI behavior easily and
40+
`Context` includes handy helpers for implementing UI behavior easily and
4141
quickly.
4242

4343
The below example uses `on` helper, which registers the event handler to the
@@ -61,9 +61,9 @@ register(MyComponent, "js-hello")
6161

6262
When you click this button, it alerts "hello".
6363

64-
## Mirroring the inputs: How to use `query` helper
64+
## Mirroring the inputs: How to use `query`
6565

66-
The next component shows how you can copy the input text into other dom element.
66+
The component below shows how to copy the input text into other dom element.
6767

6868
`query` is helper to query by the selector inside your component.
6969
`query(".dest")` is equivalent of `el.querySelector(".dest")`.
@@ -87,7 +87,7 @@ register(Mirroring, "js-mirroring")
8787
</div>
8888
```
8989

90-
## Event Delegation: The 2nd arg of `on` helper
90+
## Event Delegation: Use the 2nd arg of `on`
9191

9292
If you pass a string (a selector) as the second argument of `on` function, the
9393
event handler is only invoked when the event comes from the element which
@@ -127,7 +127,8 @@ register(OutsideClickComponent, "js-outside-click")
127127

128128
## Using Cell directly from the browser
129129

130-
The below example shows how you can use `cell` directly in the browsers.
130+
You can import directly from `https://kt3k.github.io/cell/dist.min.js` to try
131+
cell in the browser.
131132

132133
```html
133134
<script type="module">
@@ -149,8 +150,8 @@ The below example shows how you can use `cell` directly in the browsers.
149150

150151
## Use signals when making remote effect
151152

152-
`cell` recommends handling event locally, but in many cases you would also need
153-
to make effects to remote elements.
153+
Cell encourages local event handling, but in many cases you would also need to
154+
make effects to remote elements.
154155

155156
If you need to affects the components in remote places (i.e. components not an
156157
ancestor or decendant of the component), we commend using `signals` for
@@ -174,7 +175,7 @@ sig.update(1)
174175
sig.update(2)
175176
```
176177

177-
## Write test of components
178+
## Write unit tests of components
178179

179180
Use `@b-fuse/deno-dom` for polyfill `document` object. An example of basic test
180181
case of a component looks like the below:
@@ -201,6 +202,19 @@ Deno.test("A test case of Component", () => {
201202
})
202203
```
203204

205+
## Notes
206+
207+
### About local event handlers
208+
209+
We call DOM event handlers local when
210+
211+
1. it only reads the data in the bound DOM element
212+
2. and it only manipulates DOM elements inside the bound DOM element
213+
214+
The `Context` helpers in cell like `on`, `el`, `query`, and `queryAll` have
215+
focus on the retrieval and manipulation of local data and makes it easier to
216+
write local event handlers
217+
204218
## Prior art
205219

206220
- [capsule](https://github.com/capsidjs/capsule)

0 commit comments

Comments
 (0)