Overview
onConnect(cb) fires after the decorated element is connected to the live DOM. onDisconnect(cb) fires when it is removed. Both receive the element as the first argument.
focusOnMount(options?) focuses the host on the next macrotask (setTimeout of 0) so the node is committed first. It has no onUpdate, so a re-render does not focus again. If the element disconnects before that turn, the timeout is cleared.
disappear(ms) removes the host after ms milliseconds. Unmount cancels the timer. A changed ms on re-render starts a fresh countdown.
Element directives vs component hooks
|
API
|
Scope
|
Notes
|
|---|---|---|
onConnect / onDisconnect
| Per element | Element directives on a single node in the template. |
onMount / onCleanup
| Per component | Outer-function hooks for the whole component lifetime. See /docs/lifecycle/on-mount. |
focusOnMount / disappear
| Per element | focusOnMount focuses once after mount. disappear removes the node after a delay. |
eleHook
| Full imperative | Mount + onUpdate + onCleanup when you need ongoing sync. |
Element connect / disconnect log
onConnect fires after the element is appended to the live DOM tree; onDisconnect fires just before it is removed. Both receive the element itself as the first argument.
focusOnMount
Focus runs on the next macrotask after mount. Toggling the atom remounts the input and focuses it. Updating a sibling atom does not.
disappear
The host is removed from the DOM after the delay. Unmounting the parent first cancels the timer.