waltz-controls / waltz

A general purpose web application that provides the interface between SCADA(s) system and the scientific users who define and calibrate their experiments
https://waltz-docs.readthedocs.io/en/latest/
GNU General Public License v3.0
17 stars 6 forks source link

Refactor ScalarWidget #247

Open Ingvord opened 4 years ago

Ingvord commented 4 years ago

ScalarWidget MUST receive DataSource (Observable) and subscribe to it:

class ScalarWidget extends WaltzWidget {
  /**
  * @param {Observable<DataSource>} dataSource
  */
  constructor(dataSource, /*...*/){
     super(/*...*/)
     this.dataSource = dataSource;

     this.dataSource.subscribe(data => this.view.update(data))
  }

  /**
   * @return {webix.ui} this widgets UI
   */
  get view(){
     return $$(/*...*/);
  }
}

In the future all low level widgets should follow this pattern

Requires #246