Files
azuredatastudio/src/sql/base/browser/lifecycle.ts
2021-04-01 11:11:43 -07:00

27 lines
821 B
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
export function subscriptionToDisposable(sub: Subscription): IDisposable {
return {
dispose: () => {
sub.unsubscribe();
}
};
}
export class AngularDisposable extends Disposable implements OnDestroy {
public isDisposed = false;
ngOnDestroy() {
this.dispose();
this.isDisposed = true;
}
}