diff --git a/src/Umbraco.Web.UI.Client/src/core/observable-api/unique-behavior-subject.ts b/src/Umbraco.Web.UI.Client/src/core/observable-api/unique-behavior-subject.ts index c3a763b325..129676501b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/observable-api/unique-behavior-subject.ts +++ b/src/Umbraco.Web.UI.Client/src/core/observable-api/unique-behavior-subject.ts @@ -28,10 +28,10 @@ type MappingFunction = (mappable: T) => R; type MemoizationFunction = (previousResult: R, currentResult: R) => boolean; function defaultMemoization(previousValue: any, currentValue: any): boolean { - if (typeof previousValue === 'object' && typeof currentValue === 'object') { - return naiveObjectComparison(previousValue, currentValue); - } - return previousValue === currentValue; + if (typeof previousValue === 'object' && typeof currentValue === 'object') { + return naiveObjectComparison(previousValue, currentValue); + } + return previousValue === currentValue; } /** @@ -45,15 +45,15 @@ function defaultMemoization(previousValue: any, currentValue: any): boolean { * public readonly myPart = CreateObservablePart(this._data, (data) => data.myPart); */ export function CreateObservablePart ( - source$: Observable, - mappingFunction: MappingFunction, - memoizationFunction?: MemoizationFunction - ): Observable { - return source$.pipe( - map(mappingFunction), - distinctUntilChanged(memoizationFunction || defaultMemoization), - shareReplay(1) - ) + source$: Observable, + mappingFunction: MappingFunction, + memoizationFunction?: MemoizationFunction + ): Observable { + return source$.pipe( + map(mappingFunction), + distinctUntilChanged(memoizationFunction || defaultMemoization), + shareReplay(1) + ) } @@ -65,24 +65,24 @@ export function CreateObservablePart ( * Additionally the Subject ensures the data is unique, not updating any Observes unless there is an actual change of the content. */ export class UniqueBehaviorSubject extends BehaviorSubject { - constructor(initialData: T) { - super(deepFreeze(initialData)); - } + constructor(initialData: T) { + super(deepFreeze(initialData)); + } - next(newData: T): void { - const frozenData = deepFreeze(newData); + next(newData: T): void { + const frozenData = deepFreeze(newData); // Only update data if its different than current data. - if (!naiveObjectComparison(frozenData, this.getValue())) { - super.next(frozenData); - } - } + if (!naiveObjectComparison(frozenData, this.getValue())) { + super.next(frozenData); + } + } /** * Partial update data set, only works for Objects. * TODO: consider moving this into a specific class for Objects? * Consider doing similar for Array? */ - update(data: Partial) { - this.next({ ...this.getValue(), ...data }); - } + update(data: Partial) { + this.next({ ...this.getValue(), ...data }); + } }