Skip to content

@jsvision/ui / getOwner

Function: getOwner()

getOwner(): Owner | null

Defined in: ui/src/reactive/scheduler.ts:52

Get the current reactive owner scope, or null if no scope is active. Pass the returned scope to runWithOwner to attach new reactive work to it later.

Returns

Owner | null

The active Owner scope, or null outside any scope.

Example

ts
import { createRoot, getOwner, runWithOwner, effect } from '@jsvision/ui';

const scope = createRoot((_dispose) => getOwner()); // grab the scope while inside it
runWithOwner(scope, () => {
  effect(() => {}); // created under, and disposed with, `scope`
});