add 'get' method to common observable map api

This commit is contained in:
Bruno Windels 2021-04-21 17:23:49 +02:00
parent 0dc796b863
commit 1d3a2aca0e
3 changed files with 16 additions and 0 deletions

View file

@ -82,4 +82,8 @@ export class ApplyMap extends BaseObservableMap {
get size() { get size() {
return this._source.size; return this._source.size;
} }
get(key) {
return this._source.get(key);
}
} }

View file

@ -49,4 +49,9 @@ export class BaseObservableMap extends BaseObservable {
get size() { get size() {
throw new Error("unimplemented"); throw new Error("unimplemented");
} }
// eslint-disable-next-line no-unused-vars
get(key) {
throw new Error("unimplemented");
}
} }

View file

@ -128,6 +128,13 @@ export class FilteredMap extends BaseObservableMap {
}); });
return count; return count;
} }
get(key) {
const value = this._source.get(key);
if (value && this._filter(value, key)) {
return value;
}
}
} }
class FilterIterator { class FilterIterator {