Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of this.own() method in dojo

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.

like image 311
Lucian Depold Avatar asked Mar 12 '13 13:03

Lucian Depold


2 Answers

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

like image 83
Craig Swing Avatar answered Sep 20 '22 15:09

Craig Swing


The short answer is: most of the things that you define inside .own() are getting correctly removed once the widget itself is destroyed. Using .own() prevents memory leaks in your app.

like image 20
0leg Avatar answered Sep 20 '22 15:09

0leg