2023-11-30 22:59:19 -05:00
|
|
|
/*
|
2024-09-06 10:22:13 +02:00
|
|
|
Copyright 2023, 2024 New Vector Ltd.
|
2023-11-30 22:59:19 -05:00
|
|
|
|
2024-09-06 10:22:13 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
Please see LICENSE in the repository root for full details.
|
2023-11-30 22:59:19 -05:00
|
|
|
*/
|
|
|
|
|
|
2024-01-20 20:39:12 -05:00
|
|
|
import { ObservableScope } from "./ObservableScope";
|
2023-11-30 22:59:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An MVVM view model.
|
|
|
|
|
*/
|
|
|
|
|
export abstract class ViewModel {
|
2024-01-20 20:39:12 -05:00
|
|
|
protected readonly scope = new ObservableScope();
|
2023-11-30 22:59:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instructs the ViewModel to clean up its resources. If you forget to call
|
|
|
|
|
* this, there may be memory leaks!
|
|
|
|
|
*/
|
|
|
|
|
public destroy(): void {
|
2024-01-20 20:39:12 -05:00
|
|
|
this.scope.end();
|
2023-11-30 22:59:19 -05:00
|
|
|
}
|
|
|
|
|
}
|