diff --git a/src/observable/map/BaseObservableMap.ts b/src/observable/map/BaseObservableMap.ts index aa76f641..807a11e7 100644 --- a/src/observable/map/BaseObservableMap.ts +++ b/src/observable/map/BaseObservableMap.ts @@ -66,7 +66,7 @@ export abstract class BaseObservableMap extends BaseObservable, updater?: Updater): MappedMap { + mapValues(mapper: Mapper, updater?: Updater): MappedMap { return this._defaults.mapValues(this, mapper, updater); } diff --git a/src/observable/map/BaseObservableMapTransformers.ts b/src/observable/map/BaseObservableMapTransformers.ts index 3b39587d..b81ffe33 100644 --- a/src/observable/map/BaseObservableMapTransformers.ts +++ b/src/observable/map/BaseObservableMapTransformers.ts @@ -44,7 +44,7 @@ export class BaseObservableMapTransformers { return new JoinedMap([_this].concat(otherMaps)); } - mapValues(_this: BaseObservableMap, mapper: Mapper, updater?: Updater): MappedMap { + mapValues(_this: BaseObservableMap, mapper: Mapper, updater?: Updater): MappedMap { return new MappedMap(_this, mapper, updater); } @@ -57,12 +57,12 @@ export class BaseObservableMapTransformers { } } -export type Mapper = ( +export type Mapper = ( value: V, emitSpontaneousUpdate: any, -) => V; +) => MappedV; -export type Updater = (params: any, mappedValue?: V, value?: V) => void; +export type Updater = (params: any, mappedValue?: MappedV, value?: V) => void; export type Comparator = (a: V, b: V) => number; diff --git a/src/observable/map/MappedMap.ts b/src/observable/map/MappedMap.ts index bd091856..e932e1b8 100644 --- a/src/observable/map/MappedMap.ts +++ b/src/observable/map/MappedMap.ts @@ -23,24 +23,24 @@ import {SubscriptionHandle} from "../BaseObservable"; so a mapped value can emit updates on it's own with this._emitSpontaneousUpdate that is passed in the mapping function how should the mapped value be notified of an update though? and can it then decide to not propagate the update? */ -export class MappedMap extends BaseObservableMap { +export class MappedMap extends BaseObservableMap { private _source: BaseObservableMap; - private _mapper: Mapper; - private _updater?: Updater; - private _mappedValues: Map; + private _mapper: Mapper; + private _updater?: Updater; + private _mappedValues: Map; private _subscription?: SubscriptionHandle; constructor( source: BaseObservableMap, - mapper: Mapper, - updater?: Updater + mapper: Mapper, + updater?: Updater ) { - super(new BaseObservableMapTransformers()); + super(new BaseObservableMapTransformers()); this._source = source; this._mapper = mapper; this._updater = updater; - this._mappedValues = new Map(); + this._mappedValues = new Map(); } _emitSpontaneousUpdate(key: K, params: any): void { @@ -107,7 +107,7 @@ export class MappedMap extends BaseObservableMap { return this._mappedValues.size; } - get(key: K): V | undefined { + get(key: K): MappedV | undefined { return this._mappedValues.get(key); } } \ No newline at end of file