Skip to content

Documentation / @finchart/core / index / Scope

Interface: Scope ​

Defined in: packages/core/src/primitives/scope.ts:23

Owns the release of whatever was acquired under it, so the acquiring line of code registers the releasing line right next to it — the two never live in separate files with only a checklist holding them together.

Rules a consumer can rely on:

  • dispose() runs disposers in reverse registration order — what was acquired last is released first, matching dependency direction.
  • dispose() is safe to call twice; the second call does nothing.
  • One disposer throwing does not stop the rest. Everything runs, then the failures are thrown — one failure unwrapped, several as an AggregateError (the same reporting shape as Plot.destroy).
  • add() on a scope that is already disposed runs the disposer immediately. An acquisition that races past teardown must not leak forever just because it arrived late.

Properties ​

disposed ​

readonly disposed: boolean

Defined in: packages/core/src/primitives/scope.ts:24

Methods ​

add() ​

add(disposer): void

Defined in: packages/core/src/primitives/scope.ts:25

Parameters ​

disposer ​

Disposer

Returns ​

void


child() ​

child(): Scope

Defined in: packages/core/src/primitives/scope.ts:32

A scope that closes when this one closes, but can also close early on its own — a drag gesture inside a connection, a subscription inside a chart. A child disposed early removes itself from the parent, so a parent that outlives many short gestures does not grow with them.

Returns ​

Scope


dispose() ​

dispose(): void

Defined in: packages/core/src/primitives/scope.ts:33

Returns ​

void