Skip to main content

Reference

Reference

Value container, allows reference counting through #onReleased signal Intended for usage with reference-managing systems

Kind: global class

new exports.Reference()

Example

const ref: Reference<Texture> = texture_system.get(some_id);
// do work with texture
ref.release(); // we're done with the resource, texture_system will be notified
// now ref.getValue() === null, reference is no longer valid

Example

const ref: Reference<Texture> = Reference.from(texture);
ref.onReleased.add((this_ref:Reference<Texture>, texture:Texture) => {
// cleanup memory when the reference is released
texture.dispose();
});
// pass the reference to some other system for use

reference.onReleased ⇒ Signal.<this, T>

Kind: instance property of Reference

reference.bind(value)

Kind: instance method of Reference

ParamType
valueT

reference.getValue() ⇒ T

Kind: instance method of Reference

reference.release()

Release value being referenced. After this the held value is set to null This method is idempotent, calling it multiple times is safe

Kind: instance method of Reference

Reference.NULL : Readonly.<Reference>

Special NULL reference that can be used to indicate lack of reference

Kind: static property of Reference
Read only: true

Reference.from(x) ⇒ Reference.<X>

Produces a new instance of a bound reference with a given value. Same as calling bind on a new instance.

Kind: static method of Reference
See: bind

ParamType
xX