Base

Base class for all configurable classes.

Subclasses do not have to implement a constructor with its restriction of having to call super() before there is a this reference. Subclasses instead implement a construct method which is called by the Base constructor. This may call its super implementation at any time.

The Base constructor applies all configs to properties of the new instance. The instance will have been configured after the super.construct(config) is called.

See the Class System documentation in the guides for more information.

Properties

4
config: Objectreadonly

Returns a copy of the full configuration which was used to configure this object.

isConstructing: Booleanreadonly

This property is set to true before the constructor returns.

isDestroyed: Booleanreadonly

This property is set to true by destroy after destruction.

It is also one of the few properties that remains on the object after returning from destroy(). This property is often checked in code paths that may encounter a destroyed object (like some event handlers) or in the destruction path during cleanup.

isDestroying: Booleanreadonly

This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

Functions

15

Configuration

Merges the provided default configuration values with the existing defaults for this class (and its subclasses).

This method allows you to define additional or override existing default property values that apply to all instances of the class.

// All my input fields should be clearable
 Field.applyDefaults({
     clearable : true
});
ParameterTypeDescription
defaultsObjObject<String, *>

An object with the default values to set.

Events

Removes all event listeners that were registered with the passed names.

ParameterTypeDescription
nameString | Symbol

The name(s) of the event listeners to be removed.

Lifecycle

Base implementation applies configuration.

Subclasses need only implement this if they have to initialize instance specific properties required by the class. Often a construct method is unnecessary. All initialization of incoming configuration properties can be done in a set propName implementation.

ParameterTypeDescription
argsObject

Usually called with a config object, but accepts any params

Base constructor, passes arguments to construct.

ParameterTypeDescription
argsObject

Usually called with a config object, but accepts any params

destroystatic

Destroys the provided objects by calling their destroy method. Skips empty values or objects that are already destroyed.

Base.destroy(myButton, toolbar1, helloWorldMessageBox);
ParameterTypeDescription
argsObject

Objects to be destroyed

Destroys this object.

This is primarily accomplished by calling doDestroy, however, prior to calling doDestroy, isDestroying is set to true. After doDestroy returns, isDestroyed is set to true.

Do not override this method in subclasses. To provide class-specific cleanup, implement doDestroy instead.

Classes implement this method to provide custom cleanup logic before calling super.doDestroy(). The general pattern is as follows:

 class Foo extends Base {
     doDestroy() {
         // perform custom cleanup

         super.doDestroy();
     }
 }

This method is called by destroy which also prevents multiple calls from reaching doDestroy. Prior to calling doDestroy, isDestroying is set to true. Upon return, the object is fully destructed and isDestroyed is set to true.

Do not call this method directly. Instead call destroy.

Sets configuration options this object with all the properties passed in the parameter object. Timing is taken care of. If the setter of one config is called first, and references the value of another config which has not yet been set, that config will be set just in time, and the new value will be used.

ParameterTypeDescription
configObject

An object containing configurations to change.

Misc

Changes the value of a numeric property of this object smoothly over the specified duration.

ParameterTypeDescription
propertyNameString

The name of the property to change.

newValueNumber

The new value to set.

durationNumber

The duration of the change in milliseconds.

easinglinear | easeInBack | easeOutBack | easeInOutBack | easeOutBounce | easeInOutBounce | easeInCirc | easeOutCirc | easeInOutCirc | easeInCubic | easeOutCubic | easeInOutCubic | easeInElastic | easeOutElastic | easeInOutElastic | easeInExpo | easeOutExpo | easeInOutExpo | easeInQuad | easeOutQuad | easeInOutQuad | easeInQuart | easeOutQuart | easeInOutQuart | easeInQuint | easeOutQuint | easeInOutQuint | easeInSine | easeOutSine | easeInOutSine

The easing function to use.

Provides a way of calling callbacks which may have been specified as the name of a function and optionally adds scope resolution.

For example, if the callback is specified as a string, then if it is prefixed with 'this.' then the function is resolved in this object. This is useful when configuring listeners at the class level.

If the callback name is prefixed with 'up.' then the ownership hierarchy is queried using the owner property until an object with the named function is present, then the named function is called upon that object.

If a named function is not found, an error is thrown. If the function should be only called when present, and may not be present, add a ? as a suffix.

ParameterTypeDescription
fnString | function

The function to call, or the name of the function to call.

thisObjectObject

The this object of the function.

argsObject[]

The argument list to pass.

Experimental helper function, extracts the currently used configs and wraps them as an app, downloading the resulting JS file.

This function is intended to simplify creating test cases for issue reporting on Bryntum's support forum.

initClassstatic

Registers this class type with its Factory

Checks if an obj is of type using object's $$name property and doing string comparison of the property with the type parameter.

ParameterTypeDescription
typeString
Returns: Boolean
mixinstatic

Applies one or more mixins to this class and returns the produced class constructor.

For example, instead of writing this:

 class A extends Delayable(Events(Localizable(Base))) {
     // ...
 }

Using this method, one would write this:

 class A extends Base.mixin(Localizable, Events, Delayable) {
     // ...
 }

If one of the mixins specified has already been mixed into the class, it will be ignored and not mixed in a second time.

ParameterTypeDescription
mixinsfunction
Returns: function

Provides a way of locating callbacks which may have been specified as the name of a function and optionally adds scope resolution.

For example, if the callback is specified as a string, then if it is prefixed with 'this.' then the function is resolved in this object. This is useful when configuring listeners at the class level.

If the callback name is prefixed with 'up.' then the ownership hierarchy is queried using the owner property until an object with the named function is present, then the named function is called upon that object.

ParameterTypeDescription
handlerString | function

The function to call, or the name of the function to call.

thisObjObject

The this object of the function.

enforceCallabilityBoolean

Pass false if the function may not exist, and a null return value is acceptable.

Returns: Object -

{ handler, thisObj }