@angular-mdc/web
Version:
60 lines (58 loc) • 2.21 kB
JavaScript
/**
* @license
* Copyright (c) Dominic Carretto
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/trimox/angular-mdc-web/blob/master/LICENSE
*/
/**
* @fileoverview added by tsickle
* Generated from: base/component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @template FoundationType
*/
class MDCComponent {
/**
* @param {?} elementRef
* @param {?=} foundation
* @param {...?} args
*/
constructor(elementRef, foundation, ...args) {
this._elementRef = elementRef;
this.initialize(...args);
// Note that we initialize foundation here and not within the constructor's default param.
this._foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
}
/* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
/**
* @param {...?} _args
* @return {?}
*/
initialize(..._args) {
// Subclasses can override this to do any additional setup work that would be considered part of a
// "constructor". Essentially, it is a hook into the parent constructor before the foundation is
// initialized. Any additional arguments besides root and foundation will be passed in here.
}
/**
* @return {?}
*/
getDefaultFoundation() {
// Subclasses must override this method to return a properly configured foundation class for the
// component.
throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' +
'foundation class');
}
/**
* @return {?}
*/
destroy() {
var _a;
// Subclasses may implement this method to release any resources / deregister any listeners they have
// attached. An example of this might be deregistering a resize event from the window object.
(_a = this._foundation) === null || _a === void 0 ? void 0 : _a.destroy();
}
}
export { MDCComponent };
//# sourceMappingURL=base.js.map