Re: Use user_data in callback



On 23.09.2015 12:45, Norman L Smith wrote:
Hello Jay,

From /usr/share/gnome-js/signals.js

Where do I find this file "signals.js"? It is not in my file system tree.


function _connect(name, callback) {

The connect takes two arguments.

The callback argument, without binding additional arguments to 
the callback, consists of only the function and its first and 
second argument. 

lang.bind as noted in the comments below provides for the use
of "this" in the body of the callback function and binding
additional arguments to the callback function.

From /usr/share/gnome-js/lang.js

Again, no file "lang.js", neither in /usr/share/gnome-shell/** nor in
/usr/** nor in https://github.com/GNOME/gnome-shell.git


/**
 * Binds obj to callback. Makes it possible to refer to "obj"
 * using this within the callback.
 * @param {object} obj the object to bind
 * @param {function} callback callback to bind obj in
 * @param arguments additional arguments to the callback
 * @returns: a new callback
 * @type: function
 */

You will not see many examples of using the binding of additional 
arguments because of "this" being available in the callback function.

Ah ok, I see that you don't need additional arguments when you have
"this" available.


Kind regards,
Jay


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]