Cleanup by Saneamiento
This commit is contained in:
@@ -47,7 +47,7 @@ $.mount(Counter, '#sidebar-widget');
|
||||
|
||||
---
|
||||
|
||||
## 🔄 How it Works (Lifecycle & Saneamiento)
|
||||
## 🔄 How it Works (Lifecycle & Cleanup)
|
||||
|
||||
When `$.mount` is executed, it performs these critical steps to ensure a leak-free environment:
|
||||
|
||||
@@ -81,5 +81,5 @@ instance.destroy();
|
||||
| **Mount to CSS Selector** | `$.mount(App, '#root')` |
|
||||
| **Mount to DOM Node** | `$.mount(App, myElement)` |
|
||||
| **Clean & Re-mount** | Calling `$.mount` again on the same target |
|
||||
| **Total Saneamiento** | `const app = $.mount(App); app.destroy();` |
|
||||
| **Total Cleanup** | `const app = $.mount(App); app.destroy();` |
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# ⚡ Quick API Reference
|
||||
|
||||
SigPro is a high-performance micro-framework that updates the **Real DOM** surgically. No Virtual DOM, no unnecessary re-renders, and built-in **Saneamiento** (memory cleanup).
|
||||
SigPro is a high-performance micro-framework that updates the **Real DOM** surgically. No Virtual DOM, no unnecessary re-renders, and built-in **Cleanup** (memory cleanup).
|
||||
|
||||
## 🟢 Core Functions
|
||||
|
||||
@@ -9,7 +9,7 @@ SigPro is a high-performance micro-framework that updates the **Real DOM** surgi
|
||||
| **`$(val, key?)`** | `(any, string?) => Signal` | Creates a **Signal**. If `key` is provided, it persists in `localStorage`. |
|
||||
| **`$(fn)`** | `(function) => Computed` | Creates a **Computed Signal** that auto-updates when its dependencies change. |
|
||||
| **`$.watch(fn)`** | `(function) => stopFn` | **Automatic Mode:** Tracks any signal touched inside. Returns a stop function. |
|
||||
| **`$.watch(deps, fn)`** | `(Array, function) => stopFn` | **Explicit Mode:** Only runs when signals in `deps` change. Used for Saneamiento. |
|
||||
| **`$.watch(deps, fn)`** | `(Array, function) => stopFn` | **Explicit Mode:** Only runs when signals in `deps` change. Used for Cleanup. |
|
||||
| **`$.html(tag, props, kids)`** | `(string, obj, any) => Element` | The low-level DOM factory. Attaches `._cleanups` to every element. |
|
||||
| **`$.If(cond, then, else?)`** | `(Signal, fn, fn?) => Node` | Reactive conditional. Automatically destroys the "else" branch memory. |
|
||||
| **`$.For(list, itemFn)`** | `(Signal, fn) => Node` | Optimized list renderer. Manages individual item lifecycles. |
|
||||
|
||||
@@ -86,7 +86,7 @@ Input({
|
||||
});
|
||||
```
|
||||
|
||||
### Dynamic Flow & Saneamiento
|
||||
### Dynamic Flow & Cleanup
|
||||
Combine tags with Core controllers for high-performance rendering. SigPro automatically cleans up the `$.watch` instances when nodes are removed.
|
||||
```javascript
|
||||
const items = $(["Apple", "Banana", "Cherry"]);
|
||||
|
||||
@@ -35,7 +35,7 @@ $.watch(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### 2. Explicit Mode (Advanced Saneamiento) 🚀
|
||||
### 2. Explicit Mode (Advanced Cleanup) 🚀
|
||||
This mode **isolates** execution. The callback only triggers when the signals in the array change. Any other signal accessed *inside* the callback will NOT trigger a re-run. This is the "gold standard" for Routers and heavy components.
|
||||
|
||||
```javascript
|
||||
|
||||
Reference in New Issue
Block a user