Returns the currently-running reactive owner — the scope that
cleanups and child computations attach to — or undefined when called
outside any reactive scope. Sibling to listener (the
tracking scope); both are low-level introspection helpers. Most app
code never touches them.
owner() takes no arguments.
Returns: the active Computation, or undefined outside a
reactive scope. cleanup registrations attach here; child
effect / memo / root instances become its
children.
Pair with owned or runWithOwner when you need to run a
callback inside a previously-captured scope — typically when the
callback fires from outside any reactive scope (a DOM event from a
library, a queued microtask). owned captures owner() for
you, so reach for it directly unless you need the raw scope.
import { owned } from 'pota'
const cb = owned(() => {
// ...runs under the owner that was active when owned() was called
})
externalLibrary.on('event', cb)
owner is about lifetime — what disposes when;
listener is about tracking — whether signal reads
subscribe. The two are usually the same Computation, but
untrack sets listener to undefined while leaving
owner intact, and root creates a new owner without a
listener.