hydrogen-web/src/observable/list/BaseObservableList.js

38 lines
964 B
JavaScript
Raw Normal View History

2019-02-22 03:38:23 +05:30
import BaseObservableCollection from "../BaseObservableCollection.js";
export default class BaseObservableList extends BaseObservableCollection {
emitReset() {
for(let h of this._handlers) {
h.onReset();
}
}
// we need batch events, mostly on index based collection though?
// maybe we should get started without?
emitAdd(index, value) {
for(let h of this._handlers) {
h.onAdd(index, value);
}
}
emitChange(index, value, params) {
for(let h of this._handlers) {
h.onChange(index, value, params);
}
}
emitRemove(index, value) {
for(let h of this._handlers) {
h.onRemove(index, value);
}
}
// toIdx assumes the item has already
// been removed from its fromIdx
emitMove(fromIdx, toIdx, value) {
for(let h of this._handlers) {
h.onMove(fromIdx, toIdx, value);
}
}
}