Mixin: module:decor/Destroyable

module:decor/Destroyable

Mixin to track handles and release them when instance is destroyed.

Call this.own(...) on list of handles (returned from dcl/advise, dojo/on, decor/Stateful#observe, or any class (including widgets) with a destroy() or remove() method. Then call destroy() later to destroy this instance and release the resources.

Source:
Show inherited

Methods

<protected> defer(fcn, delay) → {Object}

Wrapper to setTimeout to avoid deferred functions executing after the originating widget has been destroyed.

Parameters:
Name Type Description
fcn function

Function to be executed after specified delay (or 0ms if no delay specified).

delay number

Delay in ms, defaults to 0.

Source:
Returns:

Handle with a remove method that deschedules the callback from being called.

Type
Object

destroy()

Destroy this class, releasing any resources registered via own().

Source:

<protected> own() → {Array.<Object>}

Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.

Source:
Returns:

The array of specified handles, so you can do for example: var handle = this.own(on(...))[0];

Type
Array.<Object>