Looking at some of the widgets code I keep coming across lang.hitch. What does this exactly do? What is it used for?
Any example that even I can understand?
lang.hitch will really become your friend in WAB widget development. Here is my definition:
lang.hitch enables you to keep a code block in scope. Say you have a function that has a inline function and you want to call this.map to get a refernec to the map object well if you are calling this.map from inside an inline function you are VERY like to see the error that this.map is undefined. Using lang.hitch before you call your inline function tell the inline function what 'this' is.
dojo/_base/lang — The Dojo Toolkit - Reference Guide
hitch() returns a function that will execute a given function in a given context. This function allows you to control how a function executes, particularly in asynchronous operations
thanks for the explanation now I know why in some of my functions this.map was undefined. I solved it by using var myMap = this.map in the function and referred to it in my inline function as myMap.
But the way you explained it makes much more sense.
For those of you who are reading this, and don't understand yet the implications of using the keyword "this", take a look at this very useful reference:
Retrieving data ...