mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
add 'get' method to common observable map api
This commit is contained in:
parent
0dc796b863
commit
1d3a2aca0e
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user