snappymail/dev/Knoin/AbstractModel.js

34 lines
470 B
JavaScript
Raw Normal View History

2016-07-07 05:03:30 +08:00
import {isArray, disposeObject} from 'Common/Utils';
2016-10-19 01:52:43 +08:00
export class AbstractModel
2016-07-07 05:03:30 +08:00
{
2016-09-10 06:38:16 +08:00
sModelName = '';
disposables = [];
2016-07-07 05:03:30 +08:00
/**
2016-09-10 06:38:16 +08:00
* @param {string} modelName = ''
2016-07-07 05:03:30 +08:00
*/
2016-09-10 06:38:16 +08:00
constructor(modelName = '')
2016-07-07 05:03:30 +08:00
{
this.sModelName = modelName || '';
}
regDisposables(value) {
if (isArray(value))
{
2016-10-19 01:52:43 +08:00
value.forEach((item) => {
2016-07-07 05:03:30 +08:00
this.disposables.push(item);
});
}
else if (value)
{
this.disposables.push(value);
}
}
onDestroy() {
disposeObject(this);
}
}