update on variable change

by murgiaMarco

JavaScript

export class MainPage {

    private _myVar: string = "";

    get myVar(): string {
        return this._myVar;
    }
    set myVar(value: string) {
        if (value !== this._myVar) {
            this._myVar = value;
            this.doSomething();
        }
    }

    ngOnInit() {
        this.data.changeVar.subscribe(message => this.myVar = message);
    }

    private doSomething() {
        ...
    }
}


private  _nbpActionButtons: INbpButton[] = [];

  @Input() 
  set nbpActionButtons(actionButtons: INbpButton[]){
    this._nbpActionButtons = actionButtons;
   	//Update 
    this.setRightLineSize();
  }

  get nbpActionButtons(){
    return this._nbpActionButtons;
  }