moves boilerplate to bottom of classes

This commit is contained in:
Isaiah Becker-Mayer 2022-07-09 12:17:59 -04:00
parent be570cafb0
commit deab8bdaf0
6 changed files with 99 additions and 96 deletions

View File

@ -36,22 +36,6 @@ export class ApplyMap<K, V> extends BaseObservableMap<K, V> {
this._config = config<K, V>();
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
hasApply() {
return !!this._apply;
}
@ -118,6 +102,23 @@ export class ApplyMap<K, V> extends BaseObservableMap<K, V> {
get(key: K) {
return this._source.get(key);
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
}
type Apply<K, V> = (key: K, value: V, params?: any) => void;

View File

@ -35,22 +35,6 @@ export class FilteredMap<K, V> extends BaseObservableMap<K, V> {
this._config = config<K, V>();
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V>{
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
setFilter(filter: Filter<K, V>) {
this._filter = filter;
if (this._subscription) {
@ -178,6 +162,22 @@ export class FilteredMap<K, V> extends BaseObservableMap<K, V> {
return value;
}
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V>{
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
}
class FilterIterator<K, V> {

View File

@ -33,22 +33,6 @@ export class JoinedMap<K, V> extends BaseObservableMap<K, V> {
this._config = config<K, V>();
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
onAdd(source: BaseObservableMap<K, V>, key: K, value: V) {
if (!this._isKeyAtSourceOccluded(source, key)) {
const occludingValue = this._getValueFromOccludedSources(source, key);
@ -149,6 +133,23 @@ export class JoinedMap<K, V> extends BaseObservableMap<K, V> {
}
return undefined;
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
}
class JoinedIterator<K, V> implements Iterator<[K, V]> {

View File

@ -38,22 +38,6 @@ export class LogMap<K, V> extends BaseObservableMap<K, V> {
this._config = config<K, V>();
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
private log(labelOrValues: LabelOrValues, logLevel?: LogLevel): ILogItem {
return this._log.log(labelOrValues, logLevel);
}
@ -101,4 +85,21 @@ export class LogMap<K, V> extends BaseObservableMap<K, V> {
get(key: K) {
return this._source.get(key);
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
}

View File

@ -46,22 +46,6 @@ export class MappedMap<K, V> extends BaseObservableMap<K, V> {
this._config = config<K, V>();
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V>{
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
_emitSpontaneousUpdate(key: K, params: any) {
const value = this._mappedValues.get(key);
if (value) {
@ -128,4 +112,20 @@ export class MappedMap<K, V> extends BaseObservableMap<K, V> {
get(key: K): V | undefined {
return this._mappedValues.get(key);
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V>{
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
}

View File

@ -32,22 +32,6 @@ export class ObservableMap<K, V> extends BaseObservableMap<K, V> {
this._values = new Map(initialValues);
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
update(key: K, params?: any): boolean {
const value = this._values.get(key);
if (value !== undefined) {
@ -115,6 +99,22 @@ export class ObservableMap<K, V> extends BaseObservableMap<K, V> {
keys(): Iterator<K> {
return this._values.keys();
}
join(...otherMaps: Array<typeof this>): JoinedMap<K, V> {
return this._config.join(this, ...otherMaps);
}
mapValues(mapper: Mapper<V>, updater?: Updater<V>): MappedMap<K, V> {
return this._config.mapValues(this, mapper, updater);
}
sortValues(comparator: Comparator<V>): SortedMapList {
return this._config.sortValues(this, comparator);
}
filterValues(filter: Filter<K, V>): FilteredMap<K, V> {
return this._config.filterValues(this, filter);
}
};
export function tests() {