Skip to content
Class

SourceRef

A reference to a Source, used to manage a source's lifecycle. Creating a SourceRef via Source.ref increases that source's internal reference count. As long as a source has a non-zero reference count, it is assumed to still be in use. Once all references are freed via free, the source gets disposed.

Implements: Disposable

Used by

Type parameters

ts
SourceRef<
	S extends Source = Source,
>

See Source.

Properties

freed

ts
get freed(): boolean;

Whether or not this reference has been freed via free.

source

ts
get source(): S;

The Source this ref references. Accessing this field throws an error after having freed the ref.

Methods

free()

ts
free(): void;

Frees the ref, decrementing the source's internal reference count. If the source's internal reference count reaches zero, it gets disposed. To catch bugs, this method throws if the ref is already freed.

[Symbol.dispose]()

ts
[Symbol.dispose](): void;

Calls free.

Released under the Mozilla Public License 2.0.