@aurelia/runtime
Advanced tools
Comparing version 2.0.0-beta.20 to 2.0.0-beta.21
@@ -11,2 +11,3 @@ import { Collection, IObserver } from './interfaces'; | ||
setValue(newValue: number): void; | ||
handleDirty(): void; | ||
handleCollectionChange(_arr: unknown[], _: IndexMap): void; | ||
@@ -22,4 +23,5 @@ } | ||
setValue(): void; | ||
handleDirty(): void; | ||
handleCollectionChange(_collection: Collection, _: IndexMap): void; | ||
} | ||
//# sourceMappingURL=collection-length-observer.d.ts.map |
@@ -28,2 +28,3 @@ import { ICoercionConfiguration, IObserver, InterceptorFunc } from './interfaces'; | ||
useCallback(callback: (newValue: unknown, oldValue: unknown) => void): boolean; | ||
handleDirty(): void; | ||
handleChange(): void; | ||
@@ -30,0 +31,0 @@ handleCollectionChange(): void; |
@@ -16,6 +16,9 @@ import { IIndexable } from '@aurelia/kernel'; | ||
} | ||
export interface IDirtySubscriber { | ||
handleDirty(): void; | ||
} | ||
/** | ||
* Interface of a subscriber or property change handler | ||
*/ | ||
export interface ISubscriber<TValue = unknown> { | ||
export interface ISubscriber<TValue = unknown> extends Partial<IDirtySubscriber> { | ||
handleChange(newValue: TValue, previousValue: TValue): void; | ||
@@ -47,2 +50,3 @@ } | ||
notifyCollection(collection: Collection, indexMap: IndexMap): void; | ||
notifyDirty(): void; | ||
} | ||
@@ -49,0 +53,0 @@ /** |
@@ -13,7 +13,7 @@ import { type Constructable } from '@aurelia/kernel'; | ||
<TFThis, TValue>(target: undefined, context: ClassFieldDecoratorContext<TFThis, TValue>): FieldInitializer<TFThis, TValue>; | ||
<TCThis extends Constructable, TFThis_1, TValue_1>(config: IObservableDefinition): (target: TCThis | undefined, context: ClassDecoratorContext<TCThis> | ClassFieldDecoratorContext<TFThis_1, TValue_1>) => void | FieldInitializer<TFThis_1, TValue_1>; | ||
<TCThis_1 extends Constructable>(key: PropertyKey): ObservableClassDecorator<TCThis_1>; | ||
<TFThis_2, TValue_2>(): ObservableFieldDecorator<TFThis_2, TValue_2>; | ||
<TCThis extends Constructable, TFThis, TValue>(config: IObservableDefinition): (target: TCThis | undefined, context: ClassDecoratorContext<TCThis> | ClassFieldDecoratorContext<TFThis, TValue>) => FieldInitializer<TFThis, TValue> | void; | ||
<TCThis extends Constructable>(key: PropertyKey): ObservableClassDecorator<TCThis>; | ||
<TFThis, TValue>(): ObservableFieldDecorator<TFThis, TValue>; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=observable.d.ts.map |
@@ -47,3 +47,3 @@ import { ArrayObserver } from './array-observer'; | ||
}; | ||
export declare const getObserverLookup: <T extends IObserver<unknown>>(instance: object) => Record<PropertyKey, T>; | ||
export declare const getObserverLookup: <T extends IObserver>(instance: object) => Record<PropertyKey, T>; | ||
//# sourceMappingURL=observer-locator.d.ts.map |
@@ -6,4 +6,4 @@ import type { ICollectionSubscriber, ISubscriber } from './interfaces'; | ||
(): <T extends Constructable>(value: T, context: ClassDecoratorContext) => T; | ||
<T_1 extends Constructable>(target: T_1, context: ClassDecoratorContext): T_1; | ||
<T extends Constructable>(target: T, context: ClassDecoratorContext): T; | ||
}; | ||
//# sourceMappingURL=subscriber-collection.d.ts.map |
{ | ||
"name": "@aurelia/runtime", | ||
"version": "2.0.0-beta.20", | ||
"version": "2.0.0-beta.21", | ||
"main": "dist/cjs/index.cjs", | ||
@@ -57,6 +57,6 @@ "module": "dist/esm/index.mjs", | ||
"dependencies": { | ||
"@aurelia/kernel": "2.0.0-beta.20", | ||
"@aurelia/expression-parser": "2.0.0-beta.20", | ||
"@aurelia/metadata": "2.0.0-beta.20", | ||
"@aurelia/platform": "2.0.0-beta.20" | ||
"@aurelia/kernel": "2.0.0-beta.21", | ||
"@aurelia/expression-parser": "2.0.0-beta.21", | ||
"@aurelia/metadata": "2.0.0-beta.21", | ||
"@aurelia/platform": "2.0.0-beta.21" | ||
}, | ||
@@ -63,0 +63,0 @@ "devDependencies": { |
@@ -429,2 +429,4 @@ import { | ||
const subs = this.subs; | ||
subs.notifyDirty(); | ||
const indexMap = this.indexMap; | ||
@@ -440,3 +442,3 @@ if (batching) { | ||
this.indexMap = createIndexMap(length); | ||
this.subs.notifyCollection(arr, indexMap); | ||
subs.notifyCollection(arr, indexMap); | ||
} | ||
@@ -494,2 +496,8 @@ | ||
public handleDirty() { | ||
if (this.value !== this.getValue()) { | ||
this.subs.notifyDirty(); | ||
} | ||
} | ||
/** | ||
@@ -506,3 +514,2 @@ * From interface `ICollectionSubscriber` | ||
const currValue = this.value = this.getValue(); | ||
// hmm | ||
if (prevValue !== currValue) { | ||
@@ -509,0 +516,0 @@ this.subs.notify(currValue, prevValue); |
@@ -60,2 +60,8 @@ import { Collection, IObserver, atObserver } from './interfaces'; | ||
public handleDirty() { | ||
if (this._value !== this._obj.length) { | ||
this.subs.notifyDirty(); | ||
} | ||
} | ||
public handleCollectionChange(_arr: unknown[], _: IndexMap) { | ||
@@ -65,2 +71,3 @@ const oldValue = this._value; | ||
if ((this._value = value) !== oldValue) { | ||
this.subs.notifyDirty(); | ||
this.subs.notify(this._value, oldValue); | ||
@@ -100,2 +107,8 @@ } | ||
public handleDirty() { | ||
if (this._value !== this._obj.size) { | ||
this.subs.notifyDirty(); | ||
} | ||
} | ||
public handleCollectionChange(_collection: Collection, _: IndexMap): void { | ||
@@ -102,0 +115,0 @@ const oldValue = this._value; |
@@ -143,2 +143,9 @@ import { | ||
public handleDirty(): void { | ||
if (!this._isDirty) { | ||
this._isDirty = true; | ||
this.subs.notifyDirty(); | ||
} | ||
} | ||
public handleChange(): void { | ||
@@ -145,0 +152,0 @@ this._isDirty = true; |
@@ -22,6 +22,10 @@ import { DI, IIndexable, isArray } from '@aurelia/kernel'; | ||
export interface IDirtySubscriber { | ||
handleDirty(): void; | ||
} | ||
/** | ||
* Interface of a subscriber or property change handler | ||
*/ | ||
export interface ISubscriber<TValue = unknown> { | ||
export interface ISubscriber<TValue = unknown> extends Partial<IDirtySubscriber> { | ||
handleChange(newValue: TValue, previousValue: TValue): void; | ||
@@ -57,2 +61,3 @@ } | ||
notifyCollection(collection: Collection, indexMap: IndexMap): void; | ||
notifyDirty(): void; | ||
} | ||
@@ -59,0 +64,0 @@ |
@@ -144,2 +144,4 @@ import { CollectionSizeObserver } from './collection-length-observer'; | ||
const subs = this.subs; | ||
subs.notifyDirty(); | ||
const indexMap = this.indexMap; | ||
@@ -146,0 +148,0 @@ if (batching) { |
@@ -204,2 +204,3 @@ import { AccessorType, IAccessor, ISubscriberCollection, atObserver } from './interfaces'; | ||
this._oldValue = this._value; | ||
this.subs.notifyDirty(); | ||
this.subs.notify(this._value, value); | ||
@@ -206,0 +207,0 @@ } |
@@ -104,10 +104,2 @@ import { IIndexable } from '@aurelia/kernel'; | ||
// function disableSetObservation(): void { | ||
// for (const method of methods) { | ||
// if (proto[method].observing === true) { | ||
// rtDef(proto, method, { ...descriptorProps, value: native[method] }); | ||
// } | ||
// } | ||
// } | ||
interface SetObserverImpl extends SetObserver {} | ||
@@ -126,2 +118,4 @@ class SetObserverImpl { | ||
const subs = this.subs; | ||
subs.notifyDirty(); | ||
const indexMap = this.indexMap; | ||
@@ -137,3 +131,3 @@ if (batching) { | ||
this.indexMap = createIndexMap(size); | ||
this.subs.notifyCollection(set, indexMap); | ||
subs.notifyCollection(set, indexMap); | ||
} | ||
@@ -140,0 +134,0 @@ |
@@ -64,2 +64,3 @@ import { ICoercionConfiguration, IObserver, InterceptorFunc, atObserver } from './interfaces'; | ||
this._callback?.(newValue, oV); | ||
this.subs.notifyDirty(); | ||
this.subs.notify(newValue, oV); | ||
@@ -66,0 +67,0 @@ } else { |
@@ -6,2 +6,3 @@ import { rtDef, rtDefineHiddenProp, ensureProto } from './utilities'; | ||
ICollectionSubscriber, | ||
IDirtySubscriber, | ||
IndexMap, | ||
@@ -57,2 +58,6 @@ ISubscriber, | ||
private readonly _subs: T[] = []; | ||
/** @internal */ | ||
private readonly _requestDirtySubs: IDirtySubscriber[] = []; | ||
/** @internal */ | ||
private _hasDirtySubs = false; | ||
@@ -64,2 +69,6 @@ public add(subscriber: T): boolean { | ||
this._subs[this._subs.length] = subscriber; | ||
if ('handleDirty' in subscriber) { | ||
this._requestDirtySubs[this._requestDirtySubs.length] = subscriber as IDirtySubscriber; | ||
this._hasDirtySubs = true; | ||
} | ||
++this.count; | ||
@@ -70,5 +79,10 @@ return true; | ||
public remove(subscriber: T): boolean { | ||
const idx = this._subs.indexOf(subscriber); | ||
let idx = this._subs.indexOf(subscriber); | ||
if (idx !== -1) { | ||
this._subs.splice(idx, 1); | ||
idx = this._requestDirtySubs.indexOf(subscriber as IDirtySubscriber); | ||
if (idx !== -1) { | ||
this._requestDirtySubs.splice(idx, 1); | ||
this._hasDirtySubs = this._requestDirtySubs.length > 0; | ||
} | ||
--this.count; | ||
@@ -85,2 +99,3 @@ return true; | ||
} | ||
/** | ||
@@ -93,9 +108,5 @@ * Note: change handlers may have the side-effect of adding/removing subscribers to this collection during this | ||
*/ | ||
const _subs = this._subs.slice(0) as ISubscriber[]; | ||
const len = _subs.length; | ||
let i = 0; | ||
for (; i < len; ++i) { | ||
_subs[i].handleChange(val, oldVal); | ||
for (const sub of this._subs.slice(0) as ISubscriber[]) { | ||
sub.handleChange(val, oldVal); | ||
} | ||
return; | ||
} | ||
@@ -112,2 +123,10 @@ | ||
} | ||
public notifyDirty() { | ||
if (this._hasDirtySubs) { | ||
for (const dirtySub of this._requestDirtySubs.slice(0)) { | ||
dirtySub.handleDirty(); | ||
} | ||
} | ||
} | ||
} | ||
@@ -114,0 +133,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1177388
18600
+ Added@aurelia/expression-parser@2.0.0-beta.21(transitive)
+ Added@aurelia/kernel@2.0.0-beta.21(transitive)
+ Added@aurelia/metadata@2.0.0-beta.21(transitive)
+ Added@aurelia/platform@2.0.0-beta.21(transitive)
- Removed@aurelia/expression-parser@2.0.0-beta.20(transitive)
- Removed@aurelia/kernel@2.0.0-beta.20(transitive)
- Removed@aurelia/metadata@2.0.0-beta.20(transitive)
- Removed@aurelia/platform@2.0.0-beta.20(transitive)