@rs-x/state-manager 0.4.22 → 1.0.2

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Observable, Subject, Subscription } from 'rxjs';
2
- import { IDisposable, IPropertyChange, IDisposableOwner, ISingletonFactory, SingletonFactoryWithGuid, IErrorLog, IGuidFactory, IIndexValueAccessor, IArrayIndexAccessor, IMapKeyAccessor, IPropertyValueAccessor, ISetKeyAccessor, SingletonFactory, IEqualityService, IValueMetadata, DateProperty, IDatePropertyAccessor, IObservableAccessor, IPromiseAccessor, IMultiInjectService, ContainerModule, IDeepClone, ISingletonFactoryWithIdGeneration, IInstanceGroupInfo } from '@rs-x/core';
2
+ import { IDisposable, IPropertyChange, IDisposableOwner, IKeyedInstanceFactory, GuidKeyedInstanceFactory, IErrorLog, IGuidFactory, IIndexValueAccessor, IArrayIndexAccessor, IMapKeyAccessor, IPropertyValueAccessor, ISetKeyAccessor, IProxyRegistry, KeyedInstanceFactory, IEqualityService, IValueMetadata, DateProperty, IDatePropertyAccessor, IObservableAccessor, IPromiseAccessor, IMultiInjectService, ContainerModule, IDeepClone, IGroupedKeyedInstanceFactory, IInstanceGroupInfo } from '@rs-x/core';
3
3
 
4
4
  interface IObserver<T = unknown> extends IDisposable {
5
5
  target: T | undefined;
@@ -37,10 +37,10 @@ interface IChangeSubscriptionsCreateMethods {
37
37
  onChanged: (change: IPropertyChange) => void;
38
38
  init?: (observer: IObserver) => void;
39
39
  }
40
- interface IGroupedChangeSubscriptionsForContextManager<TSubsriptionData, TData, TIdData = TData> extends ISingletonFactory<string, TData, IObserver, TIdData> {
40
+ interface IGroupedChangeSubscriptionsForContextManager<TSubsriptionData, TData, TIdData = TData> extends IKeyedInstanceFactory<string, TData, IObserver, TIdData> {
41
41
  getSubsriptionData(id: string): TSubsriptionData | undefined;
42
42
  }
43
- declare abstract class GroupedChangeSubscriptionsForContextManager<TSubsriptionData, TData extends TIdData & IChangeSubscriptionsCreateMethods, TIdData = TData> extends SingletonFactoryWithGuid<TData, IObserver> implements IGroupedChangeSubscriptionsForContextManager<TSubsriptionData, TData, TIdData> {
43
+ declare abstract class GroupedChangeSubscriptionsForContextManager<TSubsriptionData, TData extends TIdData & IChangeSubscriptionsCreateMethods, TIdData = TData> extends GuidKeyedInstanceFactory<TData, IObserver> implements IGroupedChangeSubscriptionsForContextManager<TSubsriptionData, TData, TIdData> {
44
44
  private _context;
45
45
  private readonly releaseContext;
46
46
  protected readonly _errorLog: IErrorLog;
@@ -92,8 +92,8 @@ interface IPropertyInfo extends IIndexInfo {
92
92
  setValue?: (value: unknown) => boolean;
93
93
  initializeManually?: boolean;
94
94
  }
95
- type IPropertyObserverProxyPairManager = ISingletonFactory<unknown, IPropertyInfo, IObserverProxyPair, IIndexInfo>;
96
- type IObjectPropertyObserverProxyPairManager = ISingletonFactory<unknown, unknown, IPropertyObserverProxyPairManager>;
95
+ type IPropertyObserverProxyPairManager = IKeyedInstanceFactory<unknown, IPropertyInfo, IObserverProxyPair, IIndexInfo>;
96
+ type IObjectPropertyObserverProxyPairManager = IKeyedInstanceFactory<unknown, unknown, IPropertyObserverProxyPairManager>;
97
97
 
98
98
  declare class ObserverGroup extends AbstractObserver {
99
99
  private readonly _errorLog;
@@ -123,7 +123,7 @@ interface IProxyTarget<TTarget> {
123
123
  target: TTarget;
124
124
  indexWatchRule?: IIndexWatchRule;
125
125
  }
126
- type IObjectObserverProxyPairManager<TTarget = unknown> = ISingletonFactory<unknown, IProxyTarget<TTarget>, IObserverProxyPair<TTarget>>;
126
+ type IObjectObserverProxyPairManager<TTarget = unknown> = IKeyedInstanceFactory<unknown, IProxyTarget<TTarget>, IObserverProxyPair<TTarget>>;
127
127
 
128
128
  interface IObjectObserverProxyPairFactory<TTarget = unknown> {
129
129
  readonly priority: number;
@@ -152,7 +152,7 @@ interface IArrayProxyData extends IArrayProxyIdData {
152
152
  owner?: IDisposableOwner;
153
153
  }
154
154
  type IArrayObserverProxyPair = IObserverProxyPair<unknown[]>;
155
- type IArrayProxyFactory = ISingletonFactory<unknown, IArrayProxyData, IArrayObserverProxyPair, IArrayProxyIdData>;
155
+ type IArrayProxyFactory = IKeyedInstanceFactory<unknown, IArrayProxyData, IArrayObserverProxyPair, IArrayProxyIdData>;
156
156
 
157
157
  type IArrayObserverProxyPairFactory = IObjectObserverProxyPairFactory<unknown[]>;
158
158
 
@@ -171,7 +171,7 @@ interface IDateProxyData extends IDateProxyIdData {
171
171
  owner?: IDisposableOwner;
172
172
  }
173
173
  type IDateObserverProxyPair = IObserverProxyPair<Date>;
174
- type IDateProxyFactory = ISingletonFactory<string, IDateProxyData, IDateObserverProxyPair>;
174
+ type IDateProxyFactory = IKeyedInstanceFactory<string, IDateProxyData, IDateObserverProxyPair>;
175
175
 
176
176
  type IDateOserverProxyPair = IObserverProxyPair<Date>;
177
177
  type IDateObserverProxyPairFactory = IObjectObserverProxyPairFactory<Date>;
@@ -191,7 +191,7 @@ interface IMapProxifyData extends IMapProxifyIdData {
191
191
  owner?: IDisposableOwner;
192
192
  }
193
193
  type IMapObserverProxyPair = IObserverProxyPair<Map<unknown, unknown>>;
194
- type IMapProxyFactory = ISingletonFactory<Map<unknown, unknown>, IMapProxifyData, IMapObserverProxyPair>;
194
+ type IMapProxyFactory = IKeyedInstanceFactory<Map<unknown, unknown>, IMapProxifyData, IMapObserverProxyPair>;
195
195
 
196
196
  type IMapObserverProxyPairFactory = IObjectObserverProxyPairFactory<Map<unknown, unknown>>;
197
197
 
@@ -207,7 +207,7 @@ interface IObservableProxyData {
207
207
  observable: Observable<unknown>;
208
208
  }
209
209
  type IObservableObserverProxyPair = IObserverProxyPair<Observable<unknown>>;
210
- type IObservableProxyFactory = ISingletonFactory<Observable<unknown>, IObservableProxyData, IObservableObserverProxyPair>;
210
+ type IObservableProxyFactory = IKeyedInstanceFactory<Observable<unknown>, IObservableProxyData, IObservableObserverProxyPair>;
211
211
 
212
212
  declare class ObservableObserverProxyPairFactory implements IObjectObserverProxyPairFactory<Observable<unknown>> {
213
213
  private readonly _observableProxyFactory;
@@ -230,7 +230,7 @@ interface IPromiseProxyData {
230
230
  promise: Promise<unknown>;
231
231
  }
232
232
  type IPromiseObserverProxyPair = IObserverProxyPair<Promise<unknown>>;
233
- type IPromiseProxyFactory = ISingletonFactory<Promise<unknown>, IPromiseProxyData, IPromiseObserverProxyPair>;
233
+ type IPromiseProxyFactory = IKeyedInstanceFactory<Promise<unknown>, IPromiseProxyData, IPromiseObserverProxyPair>;
234
234
 
235
235
  declare class PromiseObserverProxyPairFactory implements IObjectObserverProxyPairFactory<Promise<unknown>> {
236
236
  private readonly _promiseProxyFactory;
@@ -247,7 +247,7 @@ interface ISetProxifyData extends ISetProxifyIdData {
247
247
  owner?: IDisposableOwner;
248
248
  }
249
249
  type ISetObserverProxyPair = IObserverProxyPair<Set<unknown>>;
250
- type ISetProxyFactory = ISingletonFactory<Set<unknown>, ISetProxifyData, ISetObserverProxyPair, ISetProxifyIdData>;
250
+ type ISetProxyFactory = IKeyedInstanceFactory<Set<unknown>, ISetProxifyData, ISetObserverProxyPair, ISetProxifyIdData>;
251
251
 
252
252
  type ISetObserverProxyPairFactory = IObjectObserverProxyPairFactory<Set<unknown>>;
253
253
 
@@ -267,15 +267,7 @@ declare class ObjectObserverProxyPairFactoryProvider implements IObjectObserverP
267
267
  constructor(factories: readonly IObjectObserverProxyPairFactory[]);
268
268
  }
269
269
 
270
- interface IProxyRegistry {
271
- getProxyTarget<T>(proxyToFind: unknown): T;
272
- getProxy<T>(proxyTarget: unknown): T;
273
- register(proxyTarget: unknown, proxy: unknown): void;
274
- unregister(proxyTarget: unknown): void;
275
- isProxy(object: unknown): boolean;
276
- }
277
-
278
- declare class ObjectObserverProxyPairManager extends SingletonFactoryWithGuid<IProxyTarget<unknown>, IObserverProxyPair> implements IObjectObserverProxyPairManager {
270
+ declare class ObjectObserverProxyPairManager extends GuidKeyedInstanceFactory<IProxyTarget<unknown>, IObserverProxyPair> implements IObjectObserverProxyPairManager {
279
271
  private readonly getObserverFactoryProvider;
280
272
  private readonly _proxyRegistry;
281
273
  constructor(getObserverFactoryProvider: () => IObjectObserverProxyPairFactoryProvider, _proxyRegistry: IProxyRegistry, guidFactory: IGuidFactory);
@@ -295,7 +287,7 @@ interface IIndexObserverProxyPairFactory<TProxy = unknown> extends IDisposable {
295
287
  applies(object: unknown, propertyInfo: IPropertyInfo): boolean;
296
288
  }
297
289
 
298
- declare class ObjectPropertyObserverProxyPairManager extends SingletonFactory<unknown, unknown, IPropertyObserverProxyPairManager> implements IObjectPropertyObserverProxyPairManager {
290
+ declare class ObjectPropertyObserverProxyPairManager extends KeyedInstanceFactory<unknown, unknown, IPropertyObserverProxyPairManager> implements IObjectPropertyObserverProxyPairManager {
299
291
  private readonly _factories;
300
292
  private readonly _guidFactory;
301
293
  constructor(_factories: IIndexObserverProxyPairFactory[], _guidFactory: IGuidFactory);
@@ -313,10 +305,10 @@ interface IIndexObserverInfo<TIndex = unknown> extends IIndexObserverIdInfo<TInd
313
305
 
314
306
  type Collection = Map<unknown, unknown> | Array<unknown> | Set<unknown>;
315
307
  type ICollectionIdexObserverIdInfo = IIndexObserverIdInfo<unknown>;
316
- type ICollectionIndexObserverManager = ISingletonFactory<unknown, IIndexObserverInfo, IObserver>;
317
- type ICollectionItemObserverManager = ISingletonFactory<Collection, Collection, ICollectionIndexObserverManager>;
308
+ type ICollectionIndexObserverManager = IKeyedInstanceFactory<unknown, IIndexObserverInfo, IObserver>;
309
+ type ICollectionItemObserverManager = IKeyedInstanceFactory<Collection, Collection, ICollectionIndexObserverManager>;
318
310
 
319
- declare class CollectionItemObserverManager extends SingletonFactory<Collection, Collection, ICollectionIndexObserverManager> implements ICollectionItemObserverManager {
311
+ declare class CollectionItemObserverManager extends KeyedInstanceFactory<Collection, Collection, ICollectionIndexObserverManager> implements ICollectionItemObserverManager {
320
312
  private readonly _errorLog;
321
313
  private readonly _equalityService;
322
314
  private readonly _indexValueAccessor;
@@ -343,9 +335,9 @@ interface IndexChangeSubscriptionForContext<TIndex> {
343
335
  context: unknown;
344
336
  index: TIndex;
345
337
  }
346
- type IIndexSetObserverManager<TIndex> = ISingletonFactory<unknown, unknown, ISingletonFactory<IIndexWatchRule | TIndex, IIndexObserverInfo<TIndex>, IObserver, ISubscriptionIdInfo<TIndex>>>;
338
+ type IIndexSetObserverManager<TIndex> = IKeyedInstanceFactory<unknown, unknown, IKeyedInstanceFactory<IIndexWatchRule | TIndex, IIndexObserverInfo<TIndex>, IObserver, ISubscriptionIdInfo<TIndex>>>;
347
339
  type IIndexChangeSubscriptionsForContextManager<TIndex> = IGroupedChangeSubscriptionsForContextManager<ObserverGroup, ISubscriptionInfo<TIndex>, ISubscriptionIdInfo<TIndex>>;
348
- declare class IndexChangeSubscriptionManager<TIndex> extends SingletonFactory<unknown, unknown, IIndexChangeSubscriptionsForContextManager<TIndex>> {
340
+ declare class IndexChangeSubscriptionManager<TIndex> extends KeyedInstanceFactory<unknown, unknown, IIndexChangeSubscriptionsForContextManager<TIndex>> {
349
341
  private readonly _indexSetObserverManager;
350
342
  private readonly _errorLog;
351
343
  private readonly _guidFactory;
@@ -383,10 +375,10 @@ type ICollectionItemObserverProxyPairFactory = IIndexObserverProxyPairFactory<Co
383
375
 
384
376
  type IDatePropertyObserverIdInfo = IIndexObserverIdInfo<DateProperty>;
385
377
  type IDatePropertyObserverInfo = IIndexObserverInfo<DateProperty>;
386
- type IProperForDataObserverManager = ISingletonFactory<DateProperty, IDatePropertyObserverInfo, IObserver>;
387
- type IDatePropertyObserverManager = ISingletonFactory<Date, Date, IProperForDataObserverManager>;
378
+ type IProperForDataObserverManager = IKeyedInstanceFactory<DateProperty, IDatePropertyObserverInfo, IObserver>;
379
+ type IDatePropertyObserverManager = IKeyedInstanceFactory<Date, Date, IProperForDataObserverManager>;
388
380
 
389
- declare class DatePropertyObserverManager extends SingletonFactory<Date, Date, IProperForDataObserverManager> implements IDatePropertyObserverManager {
381
+ declare class DatePropertyObserverManager extends KeyedInstanceFactory<Date, Date, IProperForDataObserverManager> implements IDatePropertyObserverManager {
390
382
  private readonly _dateProxyFactory;
391
383
  private readonly _errorLog;
392
384
  private readonly _datePropertyAccessor;
@@ -406,8 +398,8 @@ declare class DatePropertyObserverProxyPairFactory extends IndexObserverProxyPai
406
398
 
407
399
  type IPropertyObserverIdInfo = IIndexObserverIdInfo<string>;
408
400
  type IPropertyObserverInfo = IIndexObserverInfo<string>;
409
- type IPropertyObserverManager = ISingletonFactory<string, IPropertyObserverInfo, IObserver>;
410
- type IObjectPropertyObserverManager = ISingletonFactory<object, object, IPropertyObserverManager>;
401
+ type IPropertyObserverManager = IKeyedInstanceFactory<string, IPropertyObserverInfo, IObserver>;
402
+ type IObjectPropertyObserverManager = IKeyedInstanceFactory<object, object, IPropertyObserverManager>;
411
403
 
412
404
  declare class NonIterableObjectPropertyObserverProxyPairFactory extends IndexObserverProxyPairFactory<object, string> {
413
405
  constructor(objectObserveryManager: IObjectObserverProxyPairManager, objectPropertyObserverManager: IObjectPropertyObserverManager, errorLog: IErrorLog, guidFactory: IGuidFactory, indexValueAccessor: IIndexValueAccessor, proxyRegister: IProxyRegistry, valueMetadata: IValueMetadata);
@@ -415,7 +407,7 @@ declare class NonIterableObjectPropertyObserverProxyPairFactory extends IndexObs
415
407
  protected setIndexValue(object: Record<string, unknown>, key: string, value: unknown): void;
416
408
  }
417
409
 
418
- declare class ObjectPropertyObserverManager extends SingletonFactory<object, object, IPropertyObserverManager> implements IObjectPropertyObserverManager {
410
+ declare class ObjectPropertyObserverManager extends KeyedInstanceFactory<object, object, IPropertyObserverManager> implements IObjectPropertyObserverManager {
419
411
  private readonly _proxyRegister;
420
412
  constructor(_proxyRegister: IProxyRegistry);
421
413
  getId(context: object): object;
@@ -424,7 +416,7 @@ declare class ObjectPropertyObserverManager extends SingletonFactory<object, obj
424
416
  protected releaseInstance(propertyObserverManager: IPropertyObserverManager): void;
425
417
  }
426
418
 
427
- declare class ArrayProxyFactory extends SingletonFactory<unknown[], IArrayProxyData, IArrayObserverProxyPair, IArrayProxyIdData> implements IArrayProxyFactory {
419
+ declare class ArrayProxyFactory extends KeyedInstanceFactory<unknown[], IArrayProxyData, IArrayObserverProxyPair, IArrayProxyIdData> implements IArrayProxyFactory {
428
420
  private readonly _proxyRegistry;
429
421
  constructor(_proxyRegistry: IProxyRegistry);
430
422
  getId(data: IArrayProxyIdData): unknown[];
@@ -433,7 +425,7 @@ declare class ArrayProxyFactory extends SingletonFactory<unknown[], IArrayProxyD
433
425
  protected releaseInstance(arrayObserverWithProxy: IArrayObserverProxyPair, id: unknown[]): void;
434
426
  }
435
427
 
436
- declare class DateProxyFactory extends SingletonFactoryWithGuid<IDateProxyData, IDateObserverProxyPair, IDateProxyIdData> implements IDateProxyFactory {
428
+ declare class DateProxyFactory extends GuidKeyedInstanceFactory<IDateProxyData, IDateObserverProxyPair, IDateProxyIdData> implements IDateProxyFactory {
437
429
  private readonly _proxyRegistry;
438
430
  constructor(guidFactory: IGuidFactory, _proxyRegistry: IProxyRegistry);
439
431
  protected getGroupId(data: IDateProxyIdData): Date;
@@ -454,7 +446,7 @@ declare class MapProxy extends AbstractObserver<Map<unknown, unknown>, Map<unkno
454
446
  private deleteItem;
455
447
  private emitSet;
456
448
  }
457
- declare class MapProxyFactory extends SingletonFactory<Map<unknown, unknown>, IMapProxifyData, IMapObserverProxyPair> implements IMapProxyFactory {
449
+ declare class MapProxyFactory extends KeyedInstanceFactory<Map<unknown, unknown>, IMapProxifyData, IMapObserverProxyPair> implements IMapProxyFactory {
458
450
  private readonly _proxyRegistry;
459
451
  constructor(_proxyRegistry: IProxyRegistry);
460
452
  getId(data: IMapProxifyData): Map<unknown, unknown>;
@@ -463,7 +455,7 @@ declare class MapProxyFactory extends SingletonFactory<Map<unknown, unknown>, IM
463
455
  protected releaseInstance(mapObserverWithProxy: IMapObserverProxyPair): void;
464
456
  }
465
457
 
466
- declare class ObservableProxyFactory extends SingletonFactory<Observable<unknown>, IObservableProxyData, IObservableObserverProxyPair> implements IObservableProxyFactory {
458
+ declare class ObservableProxyFactory extends KeyedInstanceFactory<Observable<unknown>, IObservableProxyData, IObservableObserverProxyPair> implements IObservableProxyFactory {
467
459
  private readonly _observableAccessor;
468
460
  constructor(_observableAccessor: IObservableAccessor);
469
461
  getId(data: IObservableProxyData): Observable<unknown>;
@@ -472,7 +464,7 @@ declare class ObservableProxyFactory extends SingletonFactory<Observable<unknown
472
464
  protected releaseInstance(observableObserverWithProxy: IObservableObserverProxyPair): void;
473
465
  }
474
466
 
475
- declare class PromiseProxyFactory extends SingletonFactory<Promise<unknown>, IPromiseProxyData, IPromiseObserverProxyPair> implements IPromiseProxyFactory {
467
+ declare class PromiseProxyFactory extends KeyedInstanceFactory<Promise<unknown>, IPromiseProxyData, IPromiseObserverProxyPair> implements IPromiseProxyFactory {
476
468
  private readonly _promiseAccessor;
477
469
  constructor(_promiseAccessor: IPromiseAccessor);
478
470
  getId(data: IPromiseProxyData): Promise<unknown>;
@@ -481,15 +473,6 @@ declare class PromiseProxyFactory extends SingletonFactory<Promise<unknown>, IPr
481
473
  protected releaseInstance(promiseObserverWithProxy: IPromiseObserverProxyPair): void;
482
474
  }
483
475
 
484
- declare class ProxyRegistry implements IProxyRegistry {
485
- private readonly _proxies;
486
- getProxyTarget<T>(proxyToFind: unknown): T;
487
- getProxy<T>(proxyTarget: unknown): T;
488
- register(proxyTarget: unknown, proxy: unknown): void;
489
- unregister(proxyTarget: unknown): void;
490
- isProxy(object: unknown): boolean;
491
- }
492
-
493
476
  declare class SetProxy extends AbstractObserver<Set<unknown>, Set<unknown>, undefined> {
494
477
  private readonly _proxyRegistry;
495
478
  private readonly updateSet;
@@ -502,7 +485,7 @@ declare class SetProxy extends AbstractObserver<Set<unknown>, Set<unknown>, unde
502
485
  private hasSet;
503
486
  private emitValueChange;
504
487
  }
505
- declare class SetProxyFactory extends SingletonFactory<Set<unknown>, ISetProxifyData, ISetObserverProxyPair, ISetProxifyIdData> implements ISetProxyFactory {
488
+ declare class SetProxyFactory extends KeyedInstanceFactory<Set<unknown>, ISetProxifyData, ISetObserverProxyPair, ISetProxifyIdData> implements ISetProxyFactory {
506
489
  private readonly _proxyRegistry;
507
490
  constructor(_proxyRegistry: IProxyRegistry);
508
491
  getId(data: ISetProxifyIdData): Set<unknown>;
@@ -521,7 +504,6 @@ declare const RsXStateManagerInjectionTokens: {
521
504
  IMapProxyFactory: symbol;
522
505
  ISetProxyFactory: symbol;
523
506
  IDateProxyFactory: symbol;
524
- IProxyRegistry: symbol;
525
507
  IPromiseProxyFactory: symbol;
526
508
  IObservableProxyFactory: symbol;
527
509
  IObjectPropertyObserverProxyPairManager: symbol;
@@ -564,15 +546,15 @@ interface IValueWithKey extends IValueKey {
564
546
  watched: boolean;
565
547
  ownerId: unknown;
566
548
  }
567
- interface IStateForObjectManager extends ISingletonFactory<unknown, IValueWithKey, IState, IValueKey> {
549
+ interface IStateForObjectManager extends IKeyedInstanceFactory<unknown, IValueWithKey, IState, IValueKey> {
568
550
  set(key: unknown, value: unknown, watched: boolean, ownerId: unknown): void;
569
551
  }
570
- interface IObjectStateManager extends ISingletonFactory<unknown, unknown, IStateForObjectManager> {
552
+ interface IObjectStateManager extends IKeyedInstanceFactory<unknown, unknown, IStateForObjectManager> {
571
553
  replaceState(key: unknown, newContext: unknown, newValue: unknown, oldContext: unknown, watched: boolean, ownerId: unknown): void;
572
554
  isRegistered(context: unknown, key: unknown): boolean;
573
555
  }
574
556
 
575
- declare class StateForObjectManager extends SingletonFactory<unknown, IValueWithKey, IState, IValueKey> implements IStateForObjectManager {
557
+ declare class StateForObjectManager extends KeyedInstanceFactory<unknown, IValueWithKey, IState, IValueKey> implements IStateForObjectManager {
576
558
  private readonly _deepClone;
577
559
  private readonly releaseContext;
578
560
  constructor(_deepClone: IDeepClone, releaseContext: VoidFunction);
@@ -583,7 +565,7 @@ declare class StateForObjectManager extends SingletonFactory<unknown, IValueWith
583
565
  protected createInstance(data: IValueWithKey): IState;
584
566
  protected onReleased(): void;
585
567
  }
586
- declare class ObjectStateManager extends SingletonFactory<unknown, unknown, IStateForObjectManager> implements IObjectStateManager {
568
+ declare class ObjectStateManager extends KeyedInstanceFactory<unknown, unknown, IStateForObjectManager> implements IObjectStateManager {
587
569
  private readonly _deepClone;
588
570
  constructor(_deepClone: IDeepClone);
589
571
  getId(object: unknown): unknown;
@@ -605,13 +587,13 @@ interface IStateChangeSubscriptionInfo extends IStateChangeSubscriptionIdInfo {
605
587
  onChanged: (change: IPropertyChange) => void;
606
588
  init?: (observer: IObserver) => void;
607
589
  }
608
- type IStateChangeSubscriptionsForContextManager = ISingletonFactoryWithIdGeneration<string, IStateChangeSubscriptionInfo, IObserver, IStateChangeSubscriptionIdInfo>;
609
- interface IStateChangeSubscriptionManager extends ISingletonFactory<unknown, unknown, IStateChangeSubscriptionsForContextManager> {
590
+ type IStateChangeSubscriptionsForContextManager = IGroupedKeyedInstanceFactory<string, IStateChangeSubscriptionInfo, IObserver, IStateChangeSubscriptionIdInfo>;
591
+ interface IStateChangeSubscriptionManager extends IKeyedInstanceFactory<unknown, unknown, IStateChangeSubscriptionsForContextManager> {
610
592
  isRegistered(context: unknown, key: unknown): boolean;
611
593
  instanceGroupInfoEntriesForContext(context: unknown): IterableIterator<IInstanceGroupInfo<string, IObserver>>;
612
594
  }
613
595
 
614
- declare class StateChangeSubscriptionManager extends SingletonFactory<unknown, unknown, IStateChangeSubscriptionsForContextManager> implements IStateChangeSubscriptionManager {
596
+ declare class StateChangeSubscriptionManager extends KeyedInstanceFactory<unknown, unknown, IStateChangeSubscriptionsForContextManager> implements IStateChangeSubscriptionManager {
615
597
  private readonly _objectObserverManager;
616
598
  private readonly _errorLog;
617
599
  private readonly _guidFactory;
@@ -638,6 +620,10 @@ interface IStateOptions {
638
620
  indexWatchRule?: IIndexWatchRule;
639
621
  ownerId?: unknown;
640
622
  }
623
+ interface IStateEventListener {
624
+ onStateChange: (change: IStateChange) => void;
625
+ onContextChanged: (change: IContextChanged) => void;
626
+ }
641
627
  interface IStateManager {
642
628
  readonly changed: Observable<IStateChange>;
643
629
  readonly contextChanged: Observable<IContextChanged>;
@@ -645,9 +631,10 @@ interface IStateManager {
645
631
  readonly endChangeCycle: Observable<void>;
646
632
  isWatched(context: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): boolean;
647
633
  watchState(context: unknown, index: unknown, options?: IStateOptions): unknown;
634
+ subscribeStateEvents(context: unknown, index: unknown, listener: IStateEventListener): () => void;
648
635
  releaseState(oontext: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): void;
649
636
  getState<T>(context: unknown, index: unknown): T;
650
- setState<T>(context: unknown, index: unknown, value: T, ownerId: unknown): void;
637
+ setState<T>(context: unknown, index: unknown, value: T, ownerId?: unknown): void;
651
638
  clear(): void;
652
639
  }
653
640
 
@@ -661,6 +648,8 @@ declare class StateManager implements IStateManager {
661
648
  private readonly _endChangeCycle;
662
649
  private readonly _stateChangeSubscriptionManager;
663
650
  private readonly _pending;
651
+ private readonly _stateEventSubscriptionsByContext;
652
+ private readonly _stateEventSubscriptionPool;
664
653
  constructor(objectObserverManager: IObjectPropertyObserverProxyPairManager, _objectStateManager: IObjectStateManager, errorLog: IErrorLog, guidFactory: IGuidFactory, _indexValueAccessor: IIndexValueAccessor, _equalityService: IEqualityService);
665
654
  get changed(): Observable<IStateChange>;
666
655
  get contextChanged(): Observable<IContextChanged>;
@@ -669,10 +658,11 @@ declare class StateManager implements IStateManager {
669
658
  toString(): string;
670
659
  isWatched(context: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): boolean;
671
660
  watchState(context: unknown, index: unknown, options?: IStateOptions): unknown;
661
+ subscribeStateEvents(context: unknown, index: unknown, listener: IStateEventListener): () => void;
672
662
  releaseState(context: unknown, index: unknown, indexWatchRule?: IIndexWatchRule): void;
673
663
  clear(): void;
674
664
  getState<T>(context: unknown, index: unknown): T;
675
- setState<T>(context: unknown, index: unknown, value: T, ownerId: unknown): void;
665
+ setState<T>(context: unknown, index: unknown, value: T, ownerId?: unknown): void;
676
666
  private internalSetState;
677
667
  private getOldValue;
678
668
  private unnsubscribeToObserverEvents;
@@ -684,12 +674,19 @@ declare class StateManager implements IStateManager {
684
674
  private tryToSubscribeToChange;
685
675
  private getValue;
686
676
  private getStateChanges;
677
+ private collectStateChanges;
687
678
  private tryRebindingNestedState;
679
+ private addStateEventSubscription;
680
+ private removeStateEventSubscription;
681
+ private emitStateChangeEvents;
682
+ private emitContextChangedEvents;
683
+ private shouldPublish;
684
+ private acquireStateEventSubscription;
685
+ private releaseStateEventSubscription;
688
686
  private setInitialValue;
689
687
  private getChainChanges;
690
688
  private getCurrentValue;
691
- private getOwnerId;
692
689
  private onChange;
693
690
  }
694
691
 
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 };
692
+ 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 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 IStateEventListener, 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, RsXStateManagerInjectionTokens, RsXStateManagerModule, SetObserverProxyPairFactory, SetProxy, SetProxyFactory, type ShouldWatchIndexPredicate, StateChangeSubscriptionManager, StateForObjectManager, StateManager, defaultObjectObserverProxyPairFactoryList, defaultPropertyObserverProxyPairFactoryList, unloadRsXStateManagerModule, watchIndexRecursiveRule };