hydrogen-web/src/domain/ViewModel.js

24 lines
754 B
JavaScript
Raw Normal View History

2020-04-18 22:46:16 +05:30
// ViewModel should just be an eventemitter, not an ObservableValue
// as in some cases it would really be more convenient to have multiple events (like telling the timeline to scroll down)
// we do need to return a disposable from EventEmitter.on, or at least have a method here to easily track a subscription to an EventEmitter
2020-04-10 02:49:49 +05:30
export class ViewModel extends ObservableValue {
constructor(options) {
super();
this.disposables = new Disposables();
this._options = options;
}
childOptions(explicitOptions) {
return Object.assign({}, this._options, explicitOptions);
}
track(disposable) {
this.disposables.track(disposable);
}
dispose() {
this.disposables.dispose();
}
}