Use of this.own() method in dojo

Lucian Depold picture Lucian Depold · Mar 12, 2013 · Viewed 15.5k times · Source

i would like to know the intention of the "this.own()" method in dojo widgets. This method is mentioned in the Dojo Api 1.8 Documentation, for example under diijit/form/button. I did not find anything that made sense to me on google. That is how the method is mentioned:

connect(obj, event, method)

Deprecated, will be removed in 2.0, use this.own(on(...)) or this.own(aspect.after(...)) instead.

Answer

Craig Swing picture Craig Swing · Mar 12, 2013

The own function is defined in dijit/Destroyable, which is a base of dijit/_WidgetBase and thus most widgets.

dijit/Destroyable is used to track handles of an instance, and then destroy them when the instance is destroyed. The application must call destroy() on the instance in order to release the handles

http://dojotoolkit.org/reference-guide/1.8/dijit/Destroyable.html

http://dojotoolkit.org/reference-guide/1.8/dojo/Evented.html