all files / src/ widget.ts

87.5% Statements 21/24
100% Branches 0/0
60% Functions 3/5
86.36% Lines 19/22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                                                                 
// Copyright (c) Nicolas Fernandez.
// Distributed under the terms of the Modified BSD License.
 
import {
  DOMWidgetModel, DOMWidgetView, ISerializers
} from '@jupyter-widgets/base';
 
import {
  EXTENSION_SPEC_VERSION
} from './version';
 
 
export
class ExampleModel extends DOMWidgetModel {
  defaults() {
    return {...super.defaults(),
      _model_name: ExampleModel.model_name,
      _model_module: ExampleModel.model_module,
      _model_module_version: ExampleModel.model_module_version,
      _view_name: ExampleModel.view_name,
      _view_module: ExampleModel.view_module,
      _view_module_version: ExampleModel.view_module_version,
      value : 'Hello World'
    };
  }
 
  static serializers: ISerializers = {
      ...DOMWidgetModel.serializers,
      // Add any extra serializers here
    }
 
  static model_name = 'ExampleModel';
  static model_module = 'clustergrammer_widget2';
  static model_module_version = EXTENSION_SPEC_VERSION;
  static view_name = 'ExampleView';  // Set to null if no view
  static view_module = 'clustergrammer_widget2';   // Set to null if no view
  static view_module_version = EXTENSION_SPEC_VERSION;
}
 
 
export
class ExampleView extends DOMWidgetView {
  render() {
    this.value_changed();
    this.model.on('change:value', this.value_changed, this);
  }
 
  value_changed() {
    this.el.textContent = this.model.get('value');
  }
}