ginebra2/chrome/js/Bind.js
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 17:59:43 +0300
changeset 5 0f2326c2a325
parent 0 1450b09d0cfd
permissions -rw-r--r--
Revision: 201024 Kit: 2010125


// Bind a function’s scope at definition instead of execution.  Useful
// for controlling the 'this' pointer in callbacks.
Function.prototype.bind = function(obj) {
    var method = this,
    temp = function() {
        return method.apply(obj, arguments);
    };

    return temp;
}

function createDelegate(object, method) {
    var shim = function()
        {
            method.apply(object, arguments);
        }

    return shim;
}