From 588da9b7193eb5ce04ab2e2622df4e1b8230602d Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 29 Sep 2021 19:25:47 -0700 Subject: [PATCH] Relax types on BaseObservableList and add helper for tests --- src/observable/list/BaseObservableList.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/observable/list/BaseObservableList.ts b/src/observable/list/BaseObservableList.ts index 9ba6559a..6d8bd1af 100644 --- a/src/observable/list/BaseObservableList.ts +++ b/src/observable/list/BaseObservableList.ts @@ -24,6 +24,17 @@ export interface IListObserver { onMove(from: number, to: number, value: T, list: BaseObservableList): void } +export function defaultObserverWith(overrides: { [key in keyof IListObserver]?: IListObserver[key] }): IListObserver { + const defaults = { + onReset(){}, + onAdd(){}, + onUpdate(){}, + onRemove(){}, + onMove(){}, + } + return Object.assign(defaults, overrides); +} + export abstract class BaseObservableList extends BaseObservable> { emitReset() { for(let h of this._handlers) { @@ -38,7 +49,7 @@ export abstract class BaseObservableList extends BaseObservable extends BaseObservable; + abstract [Symbol.iterator](); abstract get length(): number; }