diff --git a/src/observable/list/BaseObservableList.ts b/src/observable/list/BaseObservableList.ts index e2d8c3d5..9ba6559a 100644 --- a/src/observable/list/BaseObservableList.ts +++ b/src/observable/list/BaseObservableList.ts @@ -16,7 +16,15 @@ limitations under the License. import {BaseObservable} from "../BaseObservable"; -export class BaseObservableList extends BaseObservable { +export interface IListObserver { + onReset(list: BaseObservableList): void; + onAdd(index: number, value:T, list: BaseObservableList): void; + onUpdate(index: number, value: T, params: any, list: BaseObservableList): void; + onRemove(index: number, value: T, list: BaseObservableList): void + onMove(from: number, to: number, value: T, list: BaseObservableList): void +} + +export abstract class BaseObservableList extends BaseObservable> { emitReset() { for(let h of this._handlers) { h.onReset(this); @@ -24,19 +32,19 @@ export class BaseObservableList extends BaseObservable { } // we need batch events, mostly on index based collection though? // maybe we should get started without? - emitAdd(index, value) { + emitAdd(index: number, value: T): void { for(let h of this._handlers) { h.onAdd(index, value, this); } } - emitUpdate(index, value, params) { + emitUpdate(index: number, value: T, params: any): void { for(let h of this._handlers) { h.onUpdate(index, value, params, this); } } - emitRemove(index, value) { + emitRemove(index: number, value: T): void { for(let h of this._handlers) { h.onRemove(index, value, this); } @@ -44,17 +52,12 @@ export class BaseObservableList extends BaseObservable { // toIdx assumes the item has already // been removed from its fromIdx - emitMove(fromIdx, toIdx, value) { + emitMove(fromIdx: number, toIdx: number, value: T): void { for(let h of this._handlers) { h.onMove(fromIdx, toIdx, value, this); } } - [Symbol.iterator]() { - throw new Error("unimplemented"); - } - - get length() { - throw new Error("unimplemented"); - } + abstract [Symbol.iterator](): IterableIterator; + abstract get length(): number; }