Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

add handleCallback to M.Object #88

Open
FrankStierle opened this issue Nov 22, 2012 · 0 comments
Open

add handleCallback to M.Object #88

FrankStierle opened this issue Nov 22, 2012 · 0 comments

Comments

@FrankStierle
Copy link
Contributor

Please add this often used method right after bindToCaller

/**
 * Calls a method defined by a handler
 *
 * @param {Object} handler A function, or an object including target and action to use with bindToCaller.
 * @param {Object} arg One or more arguments. If more, then apply is used instead of call.
 */
handleCallback: function(handler, arg) {
    if (typeof(handler) === 'function') {
        handler(arg);
    } else if (handler && handler.target && handler.action) {
        var action = typeof(handler.action) === 'function' ? handler.action : handler.target[handler.action];
        var call   = this.bindToCaller(handler.target, action, arg);
        call();
    }
},
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant