add 'get' method to common observable map api
This commit is contained in:
parent
0dc796b863
commit
1d3a2aca0e
3 changed files with 16 additions and 0 deletions
|
@ -82,4 +82,8 @@ export class ApplyMap extends BaseObservableMap {
|
|||
get size() {
|
||||
return this._source.size;
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this._source.get(key);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,4 +49,9 @@ export class BaseObservableMap extends BaseObservable {
|
|||
get size() {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
get(key) {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,6 +128,13 @@ export class FilteredMap extends BaseObservableMap {
|
|||
});
|
||||
return count;
|
||||
}
|
||||
|
||||
get(key) {
|
||||
const value = this._source.get(key);
|
||||
if (value && this._filter(value, key)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FilterIterator {
|
||||
|
|
Reference in a new issue