Docs Help

Terms, Icons, and Labels

Many classes have shortcut names used when creating (instantiating) a class with a configuration object. The shortcut name is referred to as an alias (or xtype if the class extends Ext.Component). The alias/xtype is listed next to the class name of applicable classes for quick reference.

Access Levels

Framework classes or their members may be specified as private or protected. Else, the class / member is public. Public, protected, and private are access descriptors used to convey how and when the class or class member should be used.

Member Types

Member Syntax

Below is an example class member that we can disect to show the syntax of a class member (the lookupComponent method as viewed from the Ext.button.Button class in this case).

lookupComponent ( item ) : Ext.Component
protected

Called when a raw config object is added to this container either during initialization of the items config, or when new items are added), or {@link #insert inserted.

This method converts the passed object into an instanced child component.

This may be overridden in subclasses when special processing needs to be applied to child creation.

Parameters

item :  Object

The config object being added.

Returns
Ext.Component

The component to be added.

Let's look at each part of the member row:

Member Flags

The API documentation uses a number of flags to further commnicate the class member's function and intent. The label may be represented by a text label, an abbreviation, or an icon.

Class Icons

- Indicates a framework class

- A singleton framework class. *See the singleton flag for more information

- A component-type framework class (any class within the Ext JS framework that extends Ext.Component)

- Indicates that the class, member, or guide is new in the currently viewed version

Member Icons

- Indicates a class member of type config

- Indicates a class member of type property

- Indicates a class member of type method

- Indicates a class member of type event

- Indicates a class member of type theme variable

- Indicates a class member of type theme mixin

- Indicates that the class, member, or guide is new in the currently viewed version

Class Member Quick-Nav Menu

Just below the class name on an API doc page is a row of buttons corresponding to the types of members owned by the current class. Each button shows a count of members by type (this count is updated as filters are applied). Clicking the button will navigate you to that member section. Hovering over the member-type button will reveal a popup menu of all members of that type for quick navigation.

Getter and Setter Methods

Getting and setter methods that correlate to a class config option will show up in the methods section as well as in the configs section of both the API doc and the member-type menus just beneath the config they work with. The getter and setter method documentation will be found in the config row for easy reference.

History Bar

Your page history is kept in localstorage and displayed (using the available real estate) just below the top title bar. By default, the only search results shown are the pages matching the product / version you're currently viewing. You can expand what is displayed by clicking on the button on the right-hand side of the history bar and choosing the "All" radio option. This will show all recent pages in the history bar for all products / versions.

Within the history config menu you will also see a listing of your recent page visits. The results are filtered by the "Current Product / Version" and "All" radio options. Clicking on the button will clear the history bar as well as the history kept in local storage.

If "All" is selected in the history config menu the checkbox option for "Show product details in the history bar" will be enabled. When checked, the product/version for each historic page will show alongside the page name in the history bar. Hovering the cursor over the page names in the history bar will also show the product/version as a tooltip.

Search and Filters

Both API docs and guides can be searched for using the search field at the top of the page.

On API doc pages there is also a filter input field that filters the member rows using the filter string. In addition to filtering by string you can filter the class members by access level, inheritance, and read only. This is done using the checkboxes at the top of the page.

The checkbox at the bottom of the API class navigation tree filters the class list to include or exclude private classes.

Clicking on an empty search field will show your last 10 searches for quick navigation.

API Doc Class Metadata

Each API doc page (with the exception of Javascript primitives pages) has a menu view of metadata relating to that class. This metadata view will have one or more of the following:

Expanding and Collapsing Examples and Class Members

Runnable examples (Fiddles) are expanded on a page by default. You can collapse and expand example code blocks individually using the arrow on the top-left of the code block. You can also toggle the collapse state of all examples using the toggle button on the top-right of the page. The toggle-all state will be remembered between page loads.

Class members are collapsed on a page by default. You can expand and collapse members using the arrow icon on the left of the member row or globally using the expand / collapse all toggle button top-right.

Desktop -vs- Mobile View

Viewing the docs on narrower screens or browsers will result in a view optimized for a smaller form factor. The primary differences between the desktop and "mobile" view are:

Viewing the Class Source

The class source can be viewed by clicking on the class name at the top of an API doc page. The source for class members can be viewed by clicking on the "view source" link on the right-hand side of the member row.

Ext JS 6.5.0 - Modern Toolkit


top

Ext.Function singleton

Hierarchy

Ext.Function

Summary

A collection of useful static methods to deal with function callbacks.

No members found using the current filters

properties

methods

Instance Methods

alias ( object, methodName ) : Function

Create an alias to the provided method property with name methodName of object. Note that the execution scope will still be bound to the provided object itself.

Parameters

object :  Object/Function

methodName :  String

Returns

:Function

aliasFn

bind ( fn, [scope], [args], [appendArgs] ) : Function

Create a new function from the provided fn, change this to the provided scope, optionally overrides arguments for the call. Defaults to the arguments passed by the caller.

Ext.bind is alias for Ext.Function.bind

NOTE: This method is deprecated. Use the standard bind method of JavaScript Function instead:

 function foo () {
     ...
 }

 var fn = foo.bind(this);

This method is unavailable natively on IE8 and IE/Quirks but Ext JS provides a "polyfill" to emulate the important features of the standard bind method. In particular, the polyfill only provides binding of "this" and optional arguments.

Parameters

fn :  Function

The function to delegate.

scope :  Object (optional)

The scope (this reference) in which the function is executed. If omitted, defaults to the default global environment object (usually the browser window).

args :  Array (optional)

Overrides arguments for the call. (Defaults to the arguments passed by the caller)

appendArgs :  Boolean/Number (optional)

if True args are appended to call args instead of overriding, if a number the args are inserted at the specified position.

Returns

:Function

The new function.

bindCallback ( callback, scope, args, delay, caller ) : Function

Captures the given parameters for a later call to Ext.callback. This binding is most useful for resolving scopes for example to an Ext.app.ViewController.

The arguments match that of Ext.callback except for the args which, if provided to this method, are prepended to any arguments supplied by the eventual caller of the returned function.

Available since: 5.0.0

Parameters

callback :  Object

scope :  Object

args :  Object

delay :  Object

caller :  Object

Returns

:Function

A function that, when called, uses Ext.callback to call the captured callback.

clone ( method ) : Function

Create a "clone" of the provided method. The returned method will call the given method passing along all arguments and the "this" pointer and return its result.

Parameters

method :  Function

Returns

:Function

cloneFn

createAnimationFrame ( fn, [scope], [args], [queueStrategy] ) : Function
private pri

Creates a wrapped function that, when invoked, defers execution until the next animation frame

Parameters

fn :  Function

The function to call.

scope :  Object (optional)

The scope (this reference) in which the function is executed. Defaults to the window object.

args :  Array (optional)

The argument list to pass to the function.

queueStrategy :  Number (optional)

A bit flag that indicates how multiple calls to the returned function within the same animation frame should be handled.

  • 1: All calls will be queued - FIFO order
  • 2: Only the first call will be queued
  • 3: The last call will replace all previous calls

Defaults to: 3

Returns

:Function

createBarrier ( count, fn, scope )

Wraps the passed function in a barrier function which will call the passed function after the passed number of invocations.

Parameters

count :  Number

The number of invocations which will result in the calling of the passed function.

fn :  Function

The function to call after the required number of invocations.

scope :  Object

The scope (this reference) in which the function will be called.

createBuffered ( fn, buffer, [scope], [args] ) : Function

Creates a delegate function, optionally with a bound scope which, when called, buffers the execution of the passed function for the configured number of milliseconds. If called again within that period, the impending invocation will be canceled, and the timeout period will begin again.

Parameters

fn :  Function

The function to invoke on a buffered timer.

buffer :  Number

The number of milliseconds by which to buffer the invocation of the function.

scope :  Object (optional)

The scope (this reference) in which. the passed function is executed. If omitted, defaults to the scope specified by the caller.

args :  Array (optional)

Override arguments for the call. Defaults to the arguments passed by the caller.

Returns

:Function

A function which invokes the passed function after buffering for the specified time.

createDelayed ( fn, delay, [scope], [args], [appendArgs] ) : Function

Creates a delegate (callback) which, when called, executes after a specific delay.

Parameters

fn :  Function

The function which will be called on a delay when the returned function is called. Optionally, a replacement (or additional) argument list may be specified.

delay :  Number

The number of milliseconds to defer execution by whenever called.

scope :  Object (optional)

The scope (this reference) used by the function at execution time.

args :  Array (optional)

Override arguments for the call. (Defaults to the arguments passed by the caller)

appendArgs :  Boolean/Number (optional)

if True args are appended to call args instead of overriding, if a number the args are inserted at the specified position.

Returns

:Function

A function which, when called, executes the original function after the specified delay.

createInterceptor ( origFn, newFn, [scope], [returnValue] ) : Function

Creates an interceptor function. The passed function is called before the original one. If it returns false, the original one is not called. The resulting function returns the results of the original function. The passed function is called with the parameters of the original function. Example usage:

var sayHi = function(name){
    alert('Hi, ' + name);
};

sayHi('Fred'); // alerts "Hi, Fred"

// create a new function that validates input without
// directly modifying the original function:
var sayHiToFriend = Ext.Function.createInterceptor(sayHi, function(name){
    return name === 'Brian';
});

sayHiToFriend('Fred');  // no alert
sayHiToFriend('Brian'); // alerts "Hi, Brian"

Parameters

origFn :  Function

The original function.

newFn :  Function

The function to call before the original.

scope :  Object (optional)

The scope (this reference) in which the passed function is executed. If omitted, defaults to the scope in which the original function is called or the browser window.

returnValue :  Object (optional)

The value to return if the passed function return false.

Defaults to: null

Returns

:Function

The new function.

createSequence ( originalFn, newFn, [scope] ) : Function

Create a combined function call sequence of the original function + the passed function. The resulting function returns the results of the original function. The passed function is called with the parameters of the original function. Example usage:

var sayHi = function(name){
    alert('Hi, ' + name);
};

sayHi('Fred'); // alerts "Hi, Fred"

var sayGoodbye = Ext.Function.createSequence(sayHi, function(name){
    alert('Bye, ' + name);
});

sayGoodbye('Fred'); // both alerts show

Parameters

originalFn :  Function

The original function.

newFn :  Function

The function to sequence.

scope :  Object (optional)

The scope (this reference) in which the passed function is executed. If omitted, defaults to the scope in which the original function is called or the default global environment object (usually the browser window).

Returns

:Function

The new function.

createThrottled ( fn, interval, [scope] ) : Function

Creates a throttled version of the passed function which, when called repeatedly and rapidly, invokes the passed function only after a certain interval has elapsed since the previous invocation.

This is useful for wrapping functions which may be called repeatedly, such as a handler of a mouse move event when the processing is expensive.

Parameters

fn :  Function

The function to execute at a regular time interval.

interval :  Number

The interval in milliseconds on which the passed function is executed.

scope :  Object (optional)

The scope (this reference) in which the passed function is executed. If omitted, defaults to the scope specified by the caller.

Returns

:Function

A function which invokes the passed function at the specified interval.

defer ( fn, millis, [scope], [args], [appendArgs] ) : Number

Calls this function after the number of milliseconds specified, optionally in a specific scope. Example usage:

var sayHi = function(name){
    alert('Hi, ' + name);
}

// executes immediately:
sayHi('Fred');

// executes after 2 seconds:
Ext.Function.defer(sayHi, 2000, this, ['Fred']);

// this syntax is sometimes useful for deferring
// execution of an anonymous function:
Ext.Function.defer(function(){
    alert('Anonymous');
}, 100);

Ext.defer is alias for Ext.Function.defer

Parameters

fn :  Function

The function to defer.

millis :  Number

The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately).

scope :  Object (optional)

The scope (this reference) in which the function is executed. If omitted, defaults to the browser window.

args :  Array (optional)

Overrides arguments for the call. Defaults to the arguments passed by the caller.

appendArgs :  Boolean/Number (optional)

If true args are appended to call args instead of overriding, or, if a number, then the args are inserted at the specified position.

Defaults to: false

Returns

:Number

The timeout id that can be used with clearTimeout.

flexSetter ( setter ) : Function

A very commonly used method throughout the framework. It acts as a wrapper around another method which originally accepts 2 arguments for name and value. The wrapped function then allows "flexible" value setting of either:

  • name and value as 2 arguments
  • one single object argument with multiple key - value pairs

For example:

var setValue = Ext.Function.flexSetter(function(name, value) {
    this[name] = value;
});

// Afterwards
// Setting a single name - value
setValue('name1', 'value1');

// Settings multiple name - value pairs
setValue({
    name1: 'value1',
    name2: 'value2',
    name3: 'value3'
});

Parameters

setter :  Function

The single value setter method.

name :  String

The name of the value being set.

value :  Object

The value being set.

Returns

:Function

interceptAfter ( object, methodName, fn, [scope] ) : Function

Adds behavior to an existing method that is executed after the original behavior of the function. For example:

var soup = {
    contents: [],
    add: function(ingredient) {
        this.contents.push(ingredient);
    }
};
Ext.Function.interceptAfter(soup, "add", function(ingredient){
    // Always add a bit of extra salt
    this.contents.push("salt");
});
soup.add("water");
soup.add("onions");
soup.contents; // will contain: water, salt, onions, salt

Parameters

object :  Object

The target object

methodName :  String

Name of the method to override

fn :  Function

Function with the new behavior. It will be called with the same arguments as the original method. The return value of this function will be the return value of the new method.

scope :  Object (optional)

The scope to execute the interceptor function. Defaults to the object.

Returns

:Function

The new function just created.

interceptBefore ( object, methodName, fn, [scope] ) : Function

Adds behavior to an existing method that is executed before the original behavior of the function. For example:

var soup = {
    contents: [],
    add: function(ingredient) {
        this.contents.push(ingredient);
    }
};
Ext.Function.interceptBefore(soup, "add", function(ingredient){
    if (!this.contents.length && ingredient !== "water") {
        // Always add water to start with
        this.contents.push("water");
    }
});
soup.add("onions");
soup.add("salt");
soup.contents; // will contain: water, onions, salt

Parameters

object :  Object

The target object

methodName :  String

Name of the method to override

fn :  Function

Function with the new behavior. It will be called with the same arguments as the original method. The return value of this function will be the return value of the new method.

scope :  Object (optional)

The scope to execute the interceptor function. Defaults to the object.

Returns

:Function

The new function just created.

interval ( fn, millis, [scope], [args], [appendArgs] ) : Number

Calls this function repeatedly at a given interval, optionally in a specific scope.

Ext.defer is alias for Ext.Function.defer

Parameters

fn :  Function

The function to defer.

millis :  Number

The number of milliseconds for the setInterval call

scope :  Object (optional)

The scope (this reference) in which the function is executed. If omitted, defaults to the browser window.

args :  Array (optional)

Overrides arguments for the call. Defaults to the arguments passed by the caller.

appendArgs :  Boolean/Number (optional)

If true args are appended to call args instead of overriding, or, if a number, then the args are inserted at the specified position.

Defaults to: false

Returns

:Number

The interval id that can be used with clearInterval.

memoize ( fn, scope, hashFn ) : Function

Returns a wrapper function that caches the return value for previously processed function argument(s).

For example:

 function factorial (value) {
     var ret = value;

     while (--value > 1) {
         ret *= value;
     }

     return ret;
 }

Each call to factorial will loop and multiply to produce the answer. Using this function we can wrap the above and cache its answers:

 factorial = Ext.Function.memoize(factorial);

The returned function operates in the same manner as before, but results are stored in a cache to avoid calling the wrapped function when given the same arguments.

 var x = factorial(20);  // first time; call real factorial()
 var y = factorial(20);  // second time; return value from first call

To support multi-argument methods, you will need to provide a hashFn.

 function permutation (n, k) {
     return factorial(n) / factorial(n - k);
 }

 permutation = Ext.Function.memoize(permutation, null, function (n, k) {
     n + '-' + k;
 });

In this case, the memoize of factorial is sufficient optimization, but the example is simply to illustrate how to generate a unique key for an expensive, multi-argument method.

IMPORTANT: This cache is unbounded so be cautious of memory leaks if the memoized function is kept indefinitely or is given an unbounded set of possible arguments.

Available since: 6.0.0

Parameters

fn :  Function

Function to wrap.

scope :  Object

Optional scope in which to execute the wrapped function.

hashFn :  Function

Optional function used to compute a hash key for storing the result, based on the arguments to the original function.

Returns

:Function

The caching wrapper function.

pass ( fn, args, [scope] ) : Function

Create a new function from the provided fn, the arguments of which are pre-set to args. New arguments passed to the newly created callback when it's invoked are appended after the pre-set ones. This is especially useful when creating callbacks.

For example:

var originalFunction = function(){
    alert(Ext.Array.from(arguments).join(' '));
};

var callback = Ext.Function.pass(originalFunction, ['Hello', 'World']);

callback(); // alerts 'Hello World'
callback('by Me'); // alerts 'Hello World by Me'

Ext.pass is alias for Ext.Function.pass

Parameters

fn :  Function

The original function.

args :  Array

The arguments to pass to new callback.

scope :  Object (optional)

The scope (this reference) in which the function is executed.

Returns

:Function

The new callback function.

requestAnimationFrame ( fn, [scope], [args] ) : Number
private pri

Schedules the passed function to be called on the next animation frame.

Parameters

fn :  Function

The function to call.

scope :  Object (optional)

The scope (this reference) in which the function is executed. Defaults to the window object.

args :  Mixed[] (optional)

The argument list to pass to the function.

Returns

:Number

Timer id for the new animation frame to use when canceling it.

Ext JS 6.5.0 - Modern Toolkit