2019-07-05 03:19:24 +08:00
|
|
|
import { isArray, disposeObject } from 'Common/Utils';
|
2016-07-07 05:03:30 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export class AbstractModel {
|
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
|
|
|
*/
|
2019-07-05 03:19:24 +08:00
|
|
|
constructor(modelName = '') {
|
2016-07-07 05:03:30 +08:00
|
|
|
this.sModelName = modelName || '';
|
|
|
|
}
|
|
|
|
|
|
|
|
regDisposables(value) {
|
2019-07-05 03:19:24 +08:00
|
|
|
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);
|
|
|
|
});
|
2019-07-05 03:19:24 +08:00
|
|
|
} else if (value) {
|
2016-07-07 05:03:30 +08:00
|
|
|
this.disposables.push(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
onDestroy() {
|
2016-07-07 05:03:30 +08:00
|
|
|
disposeObject(this);
|
|
|
|
}
|
|
|
|
}
|