@rs-x/state-manager 0.4.20 → 0.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16 -9
- package/dist/index.js +46 -36
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -554,6 +554,7 @@ interface IState {
|
|
|
554
554
|
value: unknown;
|
|
555
555
|
valueCopy: unknown;
|
|
556
556
|
watched: boolean;
|
|
557
|
+
ownerId: unknown;
|
|
557
558
|
}
|
|
558
559
|
interface IValueKey {
|
|
559
560
|
key: unknown;
|
|
@@ -561,12 +562,13 @@ interface IValueKey {
|
|
|
561
562
|
interface IValueWithKey extends IValueKey {
|
|
562
563
|
value: unknown;
|
|
563
564
|
watched: boolean;
|
|
565
|
+
ownerId: unknown;
|
|
564
566
|
}
|
|
565
567
|
interface IStateForObjectManager extends ISingletonFactory<unknown, IValueWithKey, IState, IValueKey> {
|
|
566
|
-
set(key: unknown, value: unknown, watched: boolean): void;
|
|
568
|
+
set(key: unknown, value: unknown, watched: boolean, ownerId: unknown): void;
|
|
567
569
|
}
|
|
568
570
|
interface IObjectStateManager extends ISingletonFactory<unknown, unknown, IStateForObjectManager> {
|
|
569
|
-
replaceState(key: unknown, newContext: unknown, newValue: unknown, oldContext: unknown, watched: boolean): void;
|
|
571
|
+
replaceState(key: unknown, newContext: unknown, newValue: unknown, oldContext: unknown, watched: boolean, ownerId: unknown): void;
|
|
570
572
|
isRegistered(context: unknown, key: unknown): boolean;
|
|
571
573
|
}
|
|
572
574
|
|
|
@@ -575,7 +577,7 @@ declare class StateForObjectManager extends SingletonFactory<unknown, IValueWith
|
|
|
575
577
|
private readonly releaseContext;
|
|
576
578
|
constructor(_deepClone: IDeepClone, releaseContext: VoidFunction);
|
|
577
579
|
getId(data: IValueKey): unknown;
|
|
578
|
-
set(key: unknown, value: unknown, watched: boolean): void;
|
|
580
|
+
set(key: unknown, value: unknown, watched: boolean, ownerId: unknown): void;
|
|
579
581
|
protected createId(data: IValueKey): unknown;
|
|
580
582
|
private deepClone;
|
|
581
583
|
protected createInstance(data: IValueWithKey): IState;
|
|
@@ -586,7 +588,7 @@ declare class ObjectStateManager extends SingletonFactory<unknown, unknown, ISta
|
|
|
586
588
|
constructor(_deepClone: IDeepClone);
|
|
587
589
|
getId(object: unknown): unknown;
|
|
588
590
|
isRegistered(context: unknown, key: unknown): boolean;
|
|
589
|
-
replaceState(key: unknown, newContext: unknown, newValue: unknown, oldContext: unknown, watched: boolean): void;
|
|
591
|
+
replaceState(key: unknown, newContext: unknown, newValue: unknown, oldContext: unknown, watched: boolean, ownerId: unknown): void;
|
|
590
592
|
protected createId(object: unknown): unknown;
|
|
591
593
|
protected createInstance(context: unknown): IStateForObjectManager;
|
|
592
594
|
}
|
|
@@ -632,16 +634,20 @@ interface IStateChange extends IContextChanged {
|
|
|
632
634
|
newValue?: unknown;
|
|
633
635
|
watched?: boolean;
|
|
634
636
|
}
|
|
637
|
+
interface IStateOptions {
|
|
638
|
+
indexWatchRule?: IIndexWatchRule;
|
|
639
|
+
ownerId?: unknown;
|
|
640
|
+
}
|
|
635
641
|
interface IStateManager {
|
|
636
642
|
readonly changed: Observable<IStateChange>;
|
|
637
643
|
readonly contextChanged: Observable<IContextChanged>;
|
|
638
644
|
readonly startChangeCycle: Observable<void>;
|
|
639
645
|
readonly endChangeCycle: Observable<void>;
|
|
640
646
|
isWatched(context: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): boolean;
|
|
641
|
-
watchState(context: unknown, index: unknown,
|
|
647
|
+
watchState(context: unknown, index: unknown, options?: IStateOptions): unknown;
|
|
642
648
|
releaseState(oontext: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): void;
|
|
643
649
|
getState<T>(context: unknown, index: unknown): T;
|
|
644
|
-
setState<T>(context: unknown, index: unknown, value: T): void;
|
|
650
|
+
setState<T>(context: unknown, index: unknown, value: T, ownerId: unknown): void;
|
|
645
651
|
clear(): void;
|
|
646
652
|
}
|
|
647
653
|
|
|
@@ -662,11 +668,11 @@ declare class StateManager implements IStateManager {
|
|
|
662
668
|
get endChangeCycle(): Observable<void>;
|
|
663
669
|
toString(): string;
|
|
664
670
|
isWatched(context: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): boolean;
|
|
665
|
-
watchState(context: unknown, index: unknown,
|
|
671
|
+
watchState(context: unknown, index: unknown, options?: IStateOptions): unknown;
|
|
666
672
|
releaseState(context: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): void;
|
|
667
673
|
clear(): void;
|
|
668
674
|
getState<T>(context: unknown, index: unknown): T;
|
|
669
|
-
setState<T>(context: unknown, index: unknown, value: T): void;
|
|
675
|
+
setState<T>(context: unknown, index: unknown, value: T, ownerId: unknown): void;
|
|
670
676
|
private internalSetState;
|
|
671
677
|
private getOldValue;
|
|
672
678
|
private unnsubscribeToObserverEvents;
|
|
@@ -682,7 +688,8 @@ declare class StateManager implements IStateManager {
|
|
|
682
688
|
private setInitialValue;
|
|
683
689
|
private getChainChanges;
|
|
684
690
|
private getCurrentValue;
|
|
691
|
+
private getOwnerId;
|
|
685
692
|
private onChange;
|
|
686
693
|
}
|
|
687
694
|
|
|
688
|
-
export { AbstractObjectObserverProxyPairFactory, AbstractObserver, ArrayObserverProxyPairFactory, ArrayProxyFactory, type Collection, CollectionItemObserverManager, CollectionItemObserverProxyPairFactory, DateObserverProxyPairFactory, DatePropertyObserverManager, DatePropertyObserverProxyPairFactory, DateProxyFactory, GroupedChangeSubscriptionsForContextManager, type IArrayObserverProxyPair, type IArrayObserverProxyPairFactory, type IArrayProxyData, type IArrayProxyFactory, type IArrayProxyIdData, type IChangeSubscriptionsCreateMethods, type ICollectionIdexObserverIdInfo, type ICollectionIndexObserverManager, type ICollectionItemObserverManager, type ICollectionItemObserverProxyPairFactory, type IContextChanged, type IDateObserverProxyPair, type IDateObserverProxyPairFactory, type IDateOserverProxyPair, type IDatePropertyObserverIdInfo, type IDatePropertyObserverInfo, type IDatePropertyObserverManager, type IDatePropertyObserverProxyPairFactory, type IDateProxyData, type IDateProxyFactory, type IDateProxyIdData, type IGroupedChangeSubscriptionsForContextManager, type IIndexChangeSubscriptionsForContextManager, type IIndexInfo, type IIndexObserverIdInfo, type IIndexObserverInfo, type IIndexObserverProxyPairFactory, type IIndexSetObserverManager, type IIndexWatchRule, type IMapObserverProxyPair, type IMapObserverProxyPairFactory, type IMapProxifyData, type IMapProxifyIdData, type IMapProxyFactory, type IObjectChange, type IObjectObserverProxyPairFactory, type IObjectObserverProxyPairFactoryProvider, type IObjectObserverProxyPairManager, type IObjectPropertyObserverManager, type IObjectPropertyObserverProxyPairManager, type IObjectStateManager, type IObservableObserverProxyPair, type IObservableProxyData, type IObservableProxyFactory, type IObserver, type IObserverProxyPair, type IPlainObjectObserverProxyPairFactory, type IPromiseObserverProxyPair, type IPromiseProxyData, type IPromiseProxyFactory, type IProperForDataObserverManager, type IPropertyInfo, type IPropertyObserverIdInfo, type IPropertyObserverInfo, type IPropertyObserverManager, type IPropertyObserverProxyPairManager, type IProxyRegistry, type IProxyTarget, type ISetObserverProxyPair, type ISetObserverProxyPairFactory, type ISetProxifyData, type ISetProxifyIdData, type ISetProxyFactory, type IState, type IStateChange, type IStateChangeObserverInfo, type IStateChangeSubscriptionIdInfo, type IStateChangeSubscriptionInfo, type IStateChangeSubscriptionManager, type IStateChangeSubscriptionsForContextManager, type IStateForObjectManager, type IStateManager, type ISubscriptionIdInfo, type ISubscriptionInfo, type ISubscriptionWithData, type IValueKey, type IValueWithKey, type IndexChangeSubscriptionForContext, IndexChangeSubscriptionManager, IndexObserverProxyPairFactory, IndexWatchRule, MapObserverProxyPairFactory, MapProxy, MapProxyFactory, NonIterableObjectPropertyObserverProxyPairFactory, ObjectObserverProxyPairFactoryProvider, ObjectObserverProxyPairManager, ObjectPropertyObserverManager, ObjectPropertyObserverProxyPairManager, ObjectStateManager, ObservableObserverProxyPairFactory, ObservableProxyFactory, ObserverGroup, PlainObjectObserverProxyPairFactory, PromiseObserverProxyPairFactory, PromiseProxyFactory, ProxyRegistry, RsXStateManagerInjectionTokens, RsXStateManagerModule, SetObserverProxyPairFactory, SetProxy, SetProxyFactory, type ShouldWatchIndexPredicate, StateChangeSubscriptionManager, StateForObjectManager, StateManager, defaultObjectObserverProxyPairFactoryList, defaultPropertyObserverProxyPairFactoryList, unloadRsXStateManagerModule, watchIndexRecursiveRule };
|
|
695
|
+
export { AbstractObjectObserverProxyPairFactory, AbstractObserver, ArrayObserverProxyPairFactory, ArrayProxyFactory, type Collection, CollectionItemObserverManager, CollectionItemObserverProxyPairFactory, DateObserverProxyPairFactory, DatePropertyObserverManager, DatePropertyObserverProxyPairFactory, DateProxyFactory, GroupedChangeSubscriptionsForContextManager, type IArrayObserverProxyPair, type IArrayObserverProxyPairFactory, type IArrayProxyData, type IArrayProxyFactory, type IArrayProxyIdData, type IChangeSubscriptionsCreateMethods, type ICollectionIdexObserverIdInfo, type ICollectionIndexObserverManager, type ICollectionItemObserverManager, type ICollectionItemObserverProxyPairFactory, type IContextChanged, type IDateObserverProxyPair, type IDateObserverProxyPairFactory, type IDateOserverProxyPair, type IDatePropertyObserverIdInfo, type IDatePropertyObserverInfo, type IDatePropertyObserverManager, type IDatePropertyObserverProxyPairFactory, type IDateProxyData, type IDateProxyFactory, type IDateProxyIdData, type IGroupedChangeSubscriptionsForContextManager, type IIndexChangeSubscriptionsForContextManager, type IIndexInfo, type IIndexObserverIdInfo, type IIndexObserverInfo, type IIndexObserverProxyPairFactory, type IIndexSetObserverManager, type IIndexWatchRule, type IMapObserverProxyPair, type IMapObserverProxyPairFactory, type IMapProxifyData, type IMapProxifyIdData, type IMapProxyFactory, type IObjectChange, type IObjectObserverProxyPairFactory, type IObjectObserverProxyPairFactoryProvider, type IObjectObserverProxyPairManager, type IObjectPropertyObserverManager, type IObjectPropertyObserverProxyPairManager, type IObjectStateManager, type IObservableObserverProxyPair, type IObservableProxyData, type IObservableProxyFactory, type IObserver, type IObserverProxyPair, type IPlainObjectObserverProxyPairFactory, type IPromiseObserverProxyPair, type IPromiseProxyData, type IPromiseProxyFactory, type IProperForDataObserverManager, type IPropertyInfo, type IPropertyObserverIdInfo, type IPropertyObserverInfo, type IPropertyObserverManager, type IPropertyObserverProxyPairManager, type IProxyRegistry, type IProxyTarget, type ISetObserverProxyPair, type ISetObserverProxyPairFactory, type ISetProxifyData, type ISetProxifyIdData, type ISetProxyFactory, type IState, type IStateChange, type IStateChangeObserverInfo, type IStateChangeSubscriptionIdInfo, type IStateChangeSubscriptionInfo, type IStateChangeSubscriptionManager, type IStateChangeSubscriptionsForContextManager, type IStateForObjectManager, type IStateManager, type IStateOptions, type ISubscriptionIdInfo, type ISubscriptionInfo, type ISubscriptionWithData, type IValueKey, type IValueWithKey, type IndexChangeSubscriptionForContext, IndexChangeSubscriptionManager, IndexObserverProxyPairFactory, IndexWatchRule, MapObserverProxyPairFactory, MapProxy, MapProxyFactory, NonIterableObjectPropertyObserverProxyPairFactory, ObjectObserverProxyPairFactoryProvider, ObjectObserverProxyPairManager, ObjectPropertyObserverManager, ObjectPropertyObserverProxyPairManager, ObjectStateManager, ObservableObserverProxyPairFactory, ObservableProxyFactory, ObserverGroup, PlainObjectObserverProxyPairFactory, PromiseObserverProxyPairFactory, PromiseProxyFactory, ProxyRegistry, RsXStateManagerInjectionTokens, RsXStateManagerModule, SetObserverProxyPairFactory, SetProxy, SetProxyFactory, type ShouldWatchIndexPredicate, StateChangeSubscriptionManager, StateForObjectManager, StateManager, defaultObjectObserverProxyPairFactoryList, defaultPropertyObserverProxyPairFactoryList, unloadRsXStateManagerModule, watchIndexRecursiveRule };
|
package/dist/index.js
CHANGED
|
@@ -2659,7 +2659,7 @@ var StateForObjectManager = class extends SingletonFactory11 {
|
|
|
2659
2659
|
getId(data) {
|
|
2660
2660
|
return data.key;
|
|
2661
2661
|
}
|
|
2662
|
-
set(key, value, watched) {
|
|
2662
|
+
set(key, value, watched, ownerId) {
|
|
2663
2663
|
const state = this.getFromId(key);
|
|
2664
2664
|
if (state) {
|
|
2665
2665
|
state.valueCopy = this.deepClone(key, value);
|
|
@@ -2668,7 +2668,8 @@ var StateForObjectManager = class extends SingletonFactory11 {
|
|
|
2668
2668
|
this.create({
|
|
2669
2669
|
key,
|
|
2670
2670
|
value,
|
|
2671
|
-
watched
|
|
2671
|
+
watched,
|
|
2672
|
+
ownerId
|
|
2672
2673
|
});
|
|
2673
2674
|
}
|
|
2674
2675
|
}
|
|
@@ -2686,7 +2687,8 @@ var StateForObjectManager = class extends SingletonFactory11 {
|
|
|
2686
2687
|
return {
|
|
2687
2688
|
value: data.value,
|
|
2688
2689
|
valueCopy: this.deepClone(data.key, data.value),
|
|
2689
|
-
watched: data.watched
|
|
2690
|
+
watched: data.watched,
|
|
2691
|
+
ownerId: data.ownerId
|
|
2690
2692
|
};
|
|
2691
2693
|
}
|
|
2692
2694
|
onReleased() {
|
|
@@ -2707,7 +2709,7 @@ var ObjectStateManager = class extends SingletonFactory11 {
|
|
|
2707
2709
|
isRegistered(context, key) {
|
|
2708
2710
|
return !!this.getFromId(context)?.has(key);
|
|
2709
2711
|
}
|
|
2710
|
-
replaceState(key, newContext, newValue, oldContext, watched) {
|
|
2712
|
+
replaceState(key, newContext, newValue, oldContext, watched, ownerId) {
|
|
2711
2713
|
let stateForObjectManagerForNewContext;
|
|
2712
2714
|
const stateForObjectManagerForOldContext = this.getFromId(oldContext);
|
|
2713
2715
|
if (newValue === void 0) {
|
|
@@ -2721,12 +2723,13 @@ var ObjectStateManager = class extends SingletonFactory11 {
|
|
|
2721
2723
|
stateForObjectManagerForNewContext = stateForObjectManagerForOldContext;
|
|
2722
2724
|
}
|
|
2723
2725
|
if (stateForObjectManagerForNewContext) {
|
|
2724
|
-
stateForObjectManagerForNewContext.set(key, newValue, watched);
|
|
2726
|
+
stateForObjectManagerForNewContext.set(key, newValue, watched, ownerId);
|
|
2725
2727
|
} else if (newValue !== void 0) {
|
|
2726
2728
|
this.create(newContext).instance.create({
|
|
2727
2729
|
key,
|
|
2728
2730
|
value: newValue,
|
|
2729
|
-
watched
|
|
2731
|
+
watched,
|
|
2732
|
+
ownerId
|
|
2730
2733
|
});
|
|
2731
2734
|
}
|
|
2732
2735
|
}
|
|
@@ -2883,13 +2886,13 @@ var StateManager = class {
|
|
|
2883
2886
|
});
|
|
2884
2887
|
return id ? stateChangeSubscriptionsForContextManager.has(id) : false;
|
|
2885
2888
|
}
|
|
2886
|
-
watchState(context, index,
|
|
2887
|
-
if (!this.isWatched(context, index, indexWatchRule)) {
|
|
2889
|
+
watchState(context, index, options) {
|
|
2890
|
+
if (!this.isWatched(context, index, options?.indexWatchRule)) {
|
|
2888
2891
|
const value = this.getState(context, index);
|
|
2889
|
-
this.tryToSubscribeToChange(context, index, indexWatchRule);
|
|
2892
|
+
this.tryToSubscribeToChange(context, index, options?.ownerId, options?.indexWatchRule);
|
|
2890
2893
|
return value;
|
|
2891
2894
|
} else {
|
|
2892
|
-
return this.increaseStateReferenceCount(context, index, true);
|
|
2895
|
+
return this.increaseStateReferenceCount(context, index, true, options?.ownerId);
|
|
2893
2896
|
}
|
|
2894
2897
|
}
|
|
2895
2898
|
releaseState(context, index, indexWatchRule) {
|
|
@@ -2905,16 +2908,16 @@ var StateManager = class {
|
|
|
2905
2908
|
getState(context, index) {
|
|
2906
2909
|
return this._objectStateManager.getFromId(context)?.getFromId(index)?.value;
|
|
2907
2910
|
}
|
|
2908
|
-
setState(context, index, value) {
|
|
2911
|
+
setState(context, index, value, ownerId) {
|
|
2909
2912
|
this.internalSetState(context, index, value, {
|
|
2910
2913
|
context,
|
|
2911
2914
|
value: this.getState(context, index),
|
|
2912
2915
|
shouldEmitChange: truePredicate6
|
|
2913
|
-
});
|
|
2916
|
+
}, ownerId);
|
|
2914
2917
|
}
|
|
2915
|
-
internalSetState(context, index, value, transferValue) {
|
|
2916
|
-
this.tryRebindingNestedState(value, transferValue.value);
|
|
2917
|
-
this._objectStateManager.replaceState(index, context, value, transferValue.context, false);
|
|
2918
|
+
internalSetState(context, index, value, transferValue, ownerId) {
|
|
2919
|
+
this.tryRebindingNestedState(value, transferValue.value, ownerId);
|
|
2920
|
+
this._objectStateManager.replaceState(index, context, value, transferValue.context, false, ownerId);
|
|
2918
2921
|
if (!transferValue?.shouldEmitChange || transferValue.shouldEmitChange(context, index)) {
|
|
2919
2922
|
this.emitChange(context, index, value, transferValue.value, transferValue.context);
|
|
2920
2923
|
}
|
|
@@ -2950,29 +2953,30 @@ var StateManager = class {
|
|
|
2950
2953
|
newValue
|
|
2951
2954
|
});
|
|
2952
2955
|
}
|
|
2953
|
-
updateState(newContext, oldContext, index, newValue, watched) {
|
|
2954
|
-
this._objectStateManager.replaceState(index, newContext, newValue, oldContext, watched);
|
|
2956
|
+
updateState(newContext, oldContext, index, newValue, watched, ownerId) {
|
|
2957
|
+
this._objectStateManager.replaceState(index, newContext, newValue, oldContext, watched, ownerId);
|
|
2955
2958
|
}
|
|
2956
2959
|
canReleaseState(context, key) {
|
|
2957
2960
|
return this._objectStateManager.getFromId(context)?.release(key).referenceCount === 0;
|
|
2958
2961
|
}
|
|
2959
|
-
increaseStateReferenceCount(context, index, watched) {
|
|
2962
|
+
increaseStateReferenceCount(context, index, watched, ownerId) {
|
|
2960
2963
|
const state = this.getState(context, index);
|
|
2961
2964
|
this._objectStateManager.create(context).instance.create({
|
|
2962
2965
|
value: state,
|
|
2963
2966
|
key: index,
|
|
2964
|
-
watched
|
|
2967
|
+
watched,
|
|
2968
|
+
ownerId
|
|
2965
2969
|
});
|
|
2966
2970
|
return state;
|
|
2967
2971
|
}
|
|
2968
|
-
tryToSubscribeToChange(context, index, indexWatchRule, transferedValue) {
|
|
2972
|
+
tryToSubscribeToChange(context, index, ownerId, indexWatchRule, transferedValue) {
|
|
2969
2973
|
this._stateChangeSubscriptionManager.create(context).instance.create({
|
|
2970
2974
|
index,
|
|
2971
2975
|
indexWatchRule,
|
|
2972
|
-
onChanged: /* @__PURE__ */ __name((change) => this.onChange(change, true), "onChanged"),
|
|
2976
|
+
onChanged: /* @__PURE__ */ __name((change) => this.onChange(change, true, ownerId), "onChanged"),
|
|
2973
2977
|
init: /* @__PURE__ */ __name((observer) => {
|
|
2974
2978
|
if (observer.value !== void 0) {
|
|
2975
|
-
this.setInitialValue(context, index, observer.value, transferedValue, true);
|
|
2979
|
+
this.setInitialValue(context, index, observer.value, transferedValue, true, ownerId);
|
|
2976
2980
|
}
|
|
2977
2981
|
observer.init();
|
|
2978
2982
|
}, "init")
|
|
@@ -2985,13 +2989,16 @@ var StateManager = class {
|
|
|
2985
2989
|
return this.getState(context, key);
|
|
2986
2990
|
}
|
|
2987
2991
|
}
|
|
2988
|
-
getStateChanges(oldContext, newContext) {
|
|
2992
|
+
getStateChanges(oldContext, newContext, parentOwnerId) {
|
|
2989
2993
|
const oldState = this._objectStateManager.getFromId(oldContext);
|
|
2990
2994
|
if (!oldState) {
|
|
2991
2995
|
return [];
|
|
2992
2996
|
}
|
|
2993
2997
|
return Array.from(oldState.ids()).map((index) => {
|
|
2994
|
-
const { value: oldValue, watched } = oldState.getFromId(index) ?? {};
|
|
2998
|
+
const { value: oldValue, watched, ownerId } = oldState.getFromId(index) ?? {};
|
|
2999
|
+
if (ownerId !== parentOwnerId) {
|
|
3000
|
+
return [];
|
|
3001
|
+
}
|
|
2995
3002
|
const newValue = this.getValue(newContext, index);
|
|
2996
3003
|
if (oldContext === newContext && this._equalityService.isEqual(oldValue, newValue)) {
|
|
2997
3004
|
return [];
|
|
@@ -3011,12 +3018,12 @@ var StateManager = class {
|
|
|
3011
3018
|
stateInfo
|
|
3012
3019
|
] : [
|
|
3013
3020
|
stateInfo,
|
|
3014
|
-
...this.getStateChanges(oldValue, newValue)
|
|
3021
|
+
...this.getStateChanges(oldValue, newValue, ownerId)
|
|
3015
3022
|
];
|
|
3016
3023
|
}).reduce((a, b) => a.concat(b), []);
|
|
3017
3024
|
}
|
|
3018
|
-
tryRebindingNestedState(newValue, oldValue) {
|
|
3019
|
-
const stateChanges = this.getStateChanges(oldValue, newValue);
|
|
3025
|
+
tryRebindingNestedState(newValue, oldValue, ownerId) {
|
|
3026
|
+
const stateChanges = this.getStateChanges(oldValue, newValue, ownerId);
|
|
3020
3027
|
if (stateChanges.length === 0) {
|
|
3021
3028
|
return;
|
|
3022
3029
|
}
|
|
@@ -3043,7 +3050,7 @@ var StateManager = class {
|
|
|
3043
3050
|
this.internalSetState(stateChange.context, stateChange.index, stateChange.newValue, {
|
|
3044
3051
|
context: stateChange.oldContext,
|
|
3045
3052
|
value: stateChange.oldValue
|
|
3046
|
-
});
|
|
3053
|
+
}, ownerId);
|
|
3047
3054
|
continue;
|
|
3048
3055
|
}
|
|
3049
3056
|
const instanceGroupInfos = this._stateChangeSubscriptionManager.instanceGroupInfoEntriesForContext(stateChange.oldContext);
|
|
@@ -3058,12 +3065,12 @@ var StateManager = class {
|
|
|
3058
3065
|
if (indexWatchRule) {
|
|
3059
3066
|
indexWatchRule.context = stateChange.context;
|
|
3060
3067
|
}
|
|
3061
|
-
this.tryToSubscribeToChange(stateChange.context, stateChange.index, indexWatchRule, rebindingOptions);
|
|
3068
|
+
this.tryToSubscribeToChange(stateChange.context, stateChange.index, ownerId, indexWatchRule, rebindingOptions);
|
|
3062
3069
|
}
|
|
3063
3070
|
}
|
|
3064
3071
|
}
|
|
3065
|
-
setInitialValue(context, index, initialValue, transferedValue, watched) {
|
|
3066
|
-
this.updateState(context, transferedValue?.context ?? context, index, initialValue, watched);
|
|
3072
|
+
setInitialValue(context, index, initialValue, transferedValue, watched, ownerId) {
|
|
3073
|
+
this.updateState(context, transferedValue?.context ?? context, index, initialValue, watched, ownerId);
|
|
3067
3074
|
if (!transferedValue?.shouldEmitChange || transferedValue.shouldEmitChange(context, index)) {
|
|
3068
3075
|
this.emitChange(context, index, initialValue, transferedValue?.value, transferedValue?.context);
|
|
3069
3076
|
}
|
|
@@ -3079,15 +3086,18 @@ var StateManager = class {
|
|
|
3079
3086
|
value: this.getValue(chainPart.context, chainPart.index)
|
|
3080
3087
|
}));
|
|
3081
3088
|
}
|
|
3082
|
-
getCurrentValue(context,
|
|
3089
|
+
getCurrentValue(context, index) {
|
|
3083
3090
|
const value = this._pending.get(context);
|
|
3084
3091
|
if (value !== void 0) {
|
|
3085
3092
|
this._pending.delete(context);
|
|
3086
3093
|
return value;
|
|
3087
3094
|
}
|
|
3088
|
-
return this.getState(context,
|
|
3095
|
+
return this.getState(context, index);
|
|
3096
|
+
}
|
|
3097
|
+
getOwnerId(context, index) {
|
|
3098
|
+
return this._objectStateManager.getFromId(context)?.getFromId(index)?.ownerId;
|
|
3089
3099
|
}
|
|
3090
|
-
onChange(change, watched = false) {
|
|
3100
|
+
onChange(change, watched = false, ownerId) {
|
|
3091
3101
|
const chainChanges = this.getChainChanges(change.chain);
|
|
3092
3102
|
if (chainChanges.length === 0) {
|
|
3093
3103
|
return;
|
|
@@ -3096,8 +3106,8 @@ var StateManager = class {
|
|
|
3096
3106
|
try {
|
|
3097
3107
|
const chainLeaf = chainChanges[chainChanges.length - 1];
|
|
3098
3108
|
const currentValue = this.getCurrentValue(chainLeaf.context, chainLeaf.index);
|
|
3099
|
-
this.tryRebindingNestedState(change.newValue, currentValue);
|
|
3100
|
-
this.updateState(chainLeaf.context, chainLeaf.context, chainLeaf.index, chainLeaf.value, watched);
|
|
3109
|
+
this.tryRebindingNestedState(change.newValue, currentValue, ownerId);
|
|
3110
|
+
this.updateState(chainLeaf.context, chainLeaf.context, chainLeaf.index, chainLeaf.value, watched, ownerId);
|
|
3101
3111
|
chainChanges.forEach((chainChange) => this.emitChange(chainChange.context, chainChange.index, chainChange.value, chainChange.oldValue));
|
|
3102
3112
|
} finally {
|
|
3103
3113
|
this._endChangeCycle.next();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rs-x/state-manager",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.22",
|
|
4
4
|
"description": "Reactive state management layer for the RS-X framework with fine-grained change tracking",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"rxjs": "^7.8.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rs-x/core": "0.4.
|
|
35
|
+
"@rs-x/core": "0.4.22"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"tsup": "^8.5.1",
|