Void onDestroy(var a object, var Void(a) destroyFn)
Arguments
object: The object being watcheddestroyFn: The function to call when the object is destroyed. Takes the object as its argument
Usage
If additional cleanup is needed when an object is destroyed, this function registers a finalisation procedure. e.g. a record containing a file handle should make sure the file is closed when the object is deallocated.