drainUnbind
Overview
Section titled “Overview”drainUnbind flushes Regor’s pending unbind queue immediately.
Regor defers some unbind work after removeNode(...) for better runtime behavior. Use drainUnbind() when you need deterministic cleanup timing.
import { createApp, drainUnbind, html, ref } from 'regor'
const root = document.createElement('div')const show = ref(true)
const app = createApp({ template: html`<div><span r-if="show">Hello</span></div>`, setup: { show },})
app.mount(root)show(false) // schedules node removal + deferred unbind
await drainUnbind() // force pending unbind cleanup nowSignature
Section titled “Signature”drainUnbind(): Promise<void>- Safe to call when there is nothing pending.
- Useful in tests when you need cleanup completed before assertions.
- Complements
removeNodeandunbind; it does not replace app lifecycle (app.unmount()).