import * as vscode from 'vscode' ; export class DataBinding < T > { private value : T ; private valueChanged = new vscode . EventEmitter < T > ( ) ; private isActive : boolean = true ; constructor ( value ) { this . value = value ; this . isActive = true ; } public get Value ( ) : T { return this . value ; } public set Value ( value ) { if ( value !== this . value ) { this . value = value ; this . valueChanged . fire ( this . value ) ; } } public setValueIfActive ( value ) { if ( value !== this . value ) { this . value = value ; if ( this . isActive ) { this . valueChanged . fire ( this . value ) ; } } } public get ValueChanged ( ) : vscode . Event < T > { return this . valueChanged . event ; } public activate ( ) { this . isActive = true ; this . valueChanged . fire ( this . value ) ; } public deactivate ( ) { this . isActive = false ; } public dispose ( ) { this . deactivate ( ) ; this . valueChanged . dispose ( ) ; } }