This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/observable/list/BaseObservableList.js
Bruno Windels 8c5411cb7d moar WIP
2020-04-19 19:02:10 +02:00

45 lines
1.1 KiB
JavaScript

import BaseObservable from "../BaseObservable.js";
export default class BaseObservableList extends BaseObservable {
emitReset() {
for(let h of this._handlers) {
h.onReset(this);
}
}
// 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, this);
}
}
emitUpdate(index, value, params) {
for(let h of this._handlers) {
h.onUpdate(index, value, params, this);
}
}
emitRemove(index, value) {
for(let h of this._handlers) {
h.onRemove(index, value, this);
}
}
// 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, this);
}
}
[Symbol.iterator]() {
throw new Error("unimplemented");
}
get length() {
throw new Error("unimplemented");
}
}