Overview
eleHook(mountFn) is the primitive for building element directives. mountFn receives a $ (DollarChain) bound to the host element, plus any user args you define on the returned factory.
Return { onUpdate, onCleanup } to sync on re-render and tear down resources. Many Mates directives (attr, style, onIntersect, onParent) are built on eleHook.
eleHook vs htmlHook vs onConnect
|
API
|
Target
|
Notes
|
|---|---|---|
eleHook
| Host element |
Imperative access to $.el; must be an element expression.
|
htmlHook
| Child part | Renders into a template part (used by timerTemplate, masonryGrid, etc.). |
onConnect
| One-shot connect | Lightweight callback when the element connects — no update loop. |
Canvas drawing with eleHook
eleHook receives a $ (DollarChain) bound to the element. Access the raw DOM node via $.el. The returned onUpdate hook re-runs on every re-render so the canvas redraws when the reactive color atom changes.
Focus on mount
eleHook can run one-shot mount logic — focus an input without onConnect.