tagu-tagu 4.2.0 → 4.2.1

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.
Files changed (2) hide show
  1. package/README.md +29 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -449,6 +449,35 @@ document.body.appendChild(EffectExample());
449
449
  ```
450
450
  [JSFiddle](https://jsfiddle.net/do_the_simplest/ge3mbua4/3/)
451
451
 
452
+ Cleanup in `useEffect`:
453
+ ```typescript
454
+ import { button, div, useEffect, useState } from "tagu-tagu";
455
+
456
+ function EffectWithCleanupExample() {
457
+ const count = useState(0);
458
+
459
+ function incrementCount() {
460
+ count.set(count.get() + 1);
461
+ }
462
+
463
+ useEffect((effect) => {
464
+ const countValue = count.get();
465
+ effect.onCleanup(() => {
466
+ console.log("Cleanup:", countValue);
467
+ });
468
+ console.log("Count:", countValue);
469
+ });
470
+
471
+ return div([
472
+ div("See console"),
473
+ button("+", { on: { click: incrementCount } }),
474
+ ]);
475
+ }
476
+
477
+ document.body.appendChild(EffectWithCleanupExample());
478
+ ```
479
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/7L9yb6vd/2/)
480
+
452
481
  ### `If`
453
482
 
454
483
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tagu-tagu",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "A lightweight helper for vanilla `HTMLElement`, with reactivity.",
5
5
  "keywords": [
6
6
  "front-end",