tutuca 0.9.94 → 0.9.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tutuca-cli.js +23 -23
- package/dist/tutuca-dev.ext.js +27 -23
- package/dist/tutuca-dev.js +27 -23
- package/dist/tutuca-dev.min.js +1 -1
- package/package.json +1 -1
- package/skill/tutuca/core.md +9 -0
- package/skill/tutuca/patterns/coordinate-components.md +5 -0
- package/skill/tutuca/patterns/handle-events.md +7 -0
package/package.json
CHANGED
package/skill/tutuca/core.md
CHANGED
|
@@ -586,6 +586,15 @@ The content of `value` depends on the event source:
|
|
|
586
586
|
For numeric inputs, prefer `valueAsInt` / `valueAsFloat` to skip the
|
|
587
587
|
string parse.
|
|
588
588
|
|
|
589
|
+
Ask for the most granular arg the handler actually uses — `value` /
|
|
590
|
+
`valueAsInt` / `key`, not the raw `event` — when the specific value is
|
|
591
|
+
all you need. A handler that takes `event` forces every test and
|
|
592
|
+
storybook story to fabricate a DOM-event-shaped object
|
|
593
|
+
(`{ target: { value: … } }`); one that takes `value` is called with a
|
|
594
|
+
plain literal. (Genuine exceptions exist — e.g. a file input needs
|
|
595
|
+
`event` to reach `event.target.files`.) See
|
|
596
|
+
[testing.md](./testing.md) *Designing handlers so tests stay simple*.
|
|
597
|
+
|
|
589
598
|
### Event Modifiers
|
|
590
599
|
|
|
591
600
|
`@on.<event>+<mod>+<mod>=...`
|
|
@@ -24,3 +24,8 @@ selections); **send/receive** to address one known component
|
|
|
24
24
|
`scope.registerRequestHandlers({...})`, and `response` gets `(res, err)`. `ctx`
|
|
25
25
|
is always the trailing arg. `receive.init` is a convention, not a lifecycle
|
|
26
26
|
hook — dispatch it with `app.sendAtRoot("init")`.
|
|
27
|
+
|
|
28
|
+
Carry the most granular payload across the channel, not whole objects you
|
|
29
|
+
won't use — `ctx.bubble("itemSelected", [item.label])` over passing the entire
|
|
30
|
+
component. The handler then receives plain values that are easy to reproduce in
|
|
31
|
+
tests and storybook stories.
|
|
@@ -25,3 +25,10 @@ names — `value`, `valueAsInt`/`valueAsFloat`, `event`, `key`, `isAlt`,
|
|
|
25
25
|
`event.target.value` (or `.checked` for a checkbox, or `event.detail` for a
|
|
26
26
|
`CustomEvent`). Bind events declaratively with `@on.` rather than reaching for
|
|
27
27
|
the node and `addEventListener` — an outside listener bypasses the transactor.
|
|
28
|
+
|
|
29
|
+
Pass the most granular arg the handler needs — `value`/`valueAsInt`/`key`, not
|
|
30
|
+
the raw `event` — when the specific value is all the handler uses. The args
|
|
31
|
+
become plain literals, so the same call is trivial to reproduce in tests and
|
|
32
|
+
storybook stories (no need to stub a `{ target: { value: … } }` event). Reach
|
|
33
|
+
for `event` only when you truly need it (e.g. a file input reading
|
|
34
|
+
`event.target.files`).
|