What's the difference between _isEnabled and isEnabled in Anguilla?

Viewed 202

I've been following GUI extensions and notice examples use either _isEnabled or isEnabled, without the underscore. Both seem to work to extend or possibly replace existing functionality.

isEnabled

For example, the PowerTools base class (which doesn't seem to "extend" existing functionality) has:

PowerTools.BaseCommand.prototype.isEnabled = function(selection, pipeline)
{
    var p = this.properties;

    if (!p.initialized)
    {
        this.initialize();
    }

    if (!this.isToolConfigured())
    {
        return false;
    }

    if (this.isValidSelection)
    {
        return this.isValidSelection(selection, pipeline);
    }

    return true;
};

A tool can use this base class and declare .isValidSelection, for example:

PowerTools.Commands.CountItems.prototype.isValidSelection = 
                                       function (selection) { ... }

_isEnabled

I see Anguilla uses ._isEnabled for existing functionality (in Chrome's console in numerous places in the code). For example, WhereUsed has:

Tridion.Cme.Commands.WhereUsed.prototype._isAvailable =
                      function WhereUsed$_isAvailable(selection) ...

Private functions?

I'm familiar with a preceding underscore being a naming convention for private variables. Are the _isEnabled and other functions that start with an underscore "private?" If so, then

  • How should we extend (add additional functionality to existing code) these functions?
  • How should we replace (not have existing code run, but have ours run instead as in an "override") these?

I'm assuming the same approach applies to other functions that start with an underscore such as _isAvailable, and _invoke.

1 Answers
Related