This provides a proxy object that can be used to implement weak referencing. One use case is the object managers that want to clear a dictionary entry when no other references exist.
Required scripts
The Reference object requires:
/*{{ javascript("jslib/utilities.js") }}*/
Summary
Creates and returns a Reference object.
Syntax
var reference = Reference.create(objectToReference);
Summary
Decrement the reference count. When it reaches 0 the subscribed observer functions are called and the object.destroy() method is called.
Syntax
reference.remove();
Summary
Register a function to call when the reference count is 0.
Syntax
someObject.reference.subscribeDestroyed(onSomeObjectDestroyed);
Summary
Unregister a previously subscribed function.
Syntax
someObject.reference.unsubscribeDestroyed(onSomeObjectDestroyed);