how to define Ext.elevateFunction

29 Views Asked by At

"I can't find Ext.elevateFunction defined anywhere in the ExtJS documentation, yet it's being used in the codebase. I'm curious to know how it's defined."

Here is the usage of Ext.elevateFunction function in the code base:

/** * This is the target of the user-supplied Ext.elevateFunction. It wraps the * call to a function and concludes by calling {@link Ext#fireIdle}. * @since 6.5.1 * @private */

    doElevate: function() {
        var fn = elevateFn,
            args = elevateArgs,
            scope = elevateScope;

        // We really should never re-enter here, but we'll latch these vars just
        // in case.
        elevateFn = elevateArgs = elevateScope = null;
        elevateRet = args ? fn.apply(scope, args) : fn.call(scope);

        // Be sure to fire the idle event while elevated or its handlers will
        // be running in an unprivileged context.
        Ext.fireIdle();
    },

    /**
     * Runs the given `fn` directly or using the user-provided `Ext.elevateFunction`
     * (if present). After calling the `fn` the global `idle` event is fired using
     * the {@link Ext#fireIdle} method.
     *
     * @param {Function} fn 
     * @param {Object} [scope] 
     * @param {Array} [args] 
     * @param {Object} [timer] 
     * @return {Mixed} 
     * @since 6.5.1
     * @private
     */
    elevate: function(fn, scope, args
                      //<debug>
                      , timer // eslint-disable-line comma-style
                      //</debug>
    ) {
        var ret;

        if (args && !args.length) {
            args = null;
        }

        Ext._suppressIdle = false;

        //<debug>
        if (timer) {
            timer.tick();
        }
        //</debug>

        if (Ext.elevateFunction) {
            elevateFn = fn;
            elevateScope = scope;
            elevateArgs = args;

            // We reuse the same fn here to avoid GC pressure.
            Ext.elevateFunction(Ext.doElevate);

            ret = elevateRet;

            elevateRet = null;
        }
        else {
            ret = args ? fn.apply(scope, args) : fn.call(scope);

            Ext.fireIdle();
        }

        //<debug>
        if (timer) {
            timer.tock();
        }
        //</debug>

        return ret;
    },

I checked on EXT namespace, the elevateFunction is undefined.

0

There are 0 best solutions below