@rs-x/state-manager 0.4.22 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rs-x/state-manager",
3
- "version": "0.4.22",
3
+ "version": "1.0.1",
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,11 +32,12 @@
32
32
  "rxjs": "^7.8.0"
33
33
  },
34
34
  "dependencies": {
35
- "@rs-x/core": "0.4.22"
35
+ "@rs-x/core": "1.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "tsup": "^8.5.1",
39
- "rimraf": "^6.1.2"
38
+ "globals": "^17.3.0",
39
+ "rimraf": "^6.1.2",
40
+ "tsup": "^8.5.1"
40
41
  },
41
42
  "engines": {
42
43
  "node": ">=24"
package/readme.md CHANGED
@@ -337,7 +337,9 @@ export const run = (() => {
337
337
  // so we pass a predicate that always returns true.
338
338
  // This will emit an initial value { y: 10 }
339
339
  console.log('Initial value:');
340
- stateManager.watchState(model, 'x', watchIndexRecursiveRule);
340
+ stateManager.watchState(model, 'x', {
341
+ indexWatchRule: watchIndexRecursiveRule,
342
+ });
341
343
 
342
344
  console.log('Changed value:');
343
345
  // This will emit the new value { y: 10 }
@@ -432,7 +434,7 @@ export const run = (() => {
432
434
  }
433
435
 
434
436
  private setAPlusB(): void {
435
- stateManager.setState(this, this._aPlusBId, this._a + this._b);
437
+ stateManager.setState(this, this._aPlusBId, this._a + this._b, undefined);
436
438
  }
437
439
  }
438
440
 
@@ -655,7 +657,9 @@ export const run = (() => {
655
657
  // Otherwise, only assigning a new value to model.b would emit a change event.
656
658
  // This will emit a change event with the initial (current) value.
657
659
  console.log('Initial value:');
658
- stateManager.watchState(model, 'b', watchIndexRecursiveRule);
660
+ stateManager.watchState(model, 'b', {
661
+ indexWatchRule: watchIndexRecursiveRule,
662
+ });
659
663
 
660
664
  console.log('\nReplacing model.b.nested.nested will emit a change event');
661
665
  console.log('Changed value:');
@@ -759,7 +763,9 @@ function watchDate(stateManager: IStateManager) {
759
763
  );
760
764
  try {
761
765
  console.log('Initial value:');
762
- stateManager.watchState(model, 'date', watchIndexRecursiveRule);
766
+ stateManager.watchState(model, 'date', {
767
+ indexWatchRule: watchIndexRecursiveRule,
768
+ });
763
769
 
764
770
  console.log('Changed value:');
765
771
  model.date.setFullYear(2023);
@@ -883,7 +889,9 @@ export const run = (() => {
883
889
  try {
884
890
  // This will emit a change event with the initial (current) value.
885
891
  console.log('Initial value:');
886
- stateManager.watchState(model, 'array', watchIndexRecursiveRule);
892
+ stateManager.watchState(model, 'array', {
893
+ indexWatchRule: watchIndexRecursiveRule,
894
+ });
887
895
 
888
896
  console.log('Changed value:');
889
897
  model.array[1].push(5);
@@ -977,7 +985,9 @@ export const run = (() => {
977
985
  try {
978
986
  // This will emit a change event with the initial (current) value.
979
987
  console.log('Initial value:');
980
- stateManager.watchState(model, 'map', watchIndexRecursiveRule);
988
+ stateManager.watchState(model, 'map', {
989
+ indexWatchRule: watchIndexRecursiveRule,
990
+ });
981
991
 
982
992
  console.log('Changed value:');
983
993
  model.map.get('b')?.push(5);
@@ -1087,7 +1097,9 @@ export const run = (() => {
1087
1097
  try {
1088
1098
  // This will emit a change event with the initial (current) value.
1089
1099
  console.log('Initial value:');
1090
- stateManager.watchState(model, 'set', watchIndexRecursiveRule);
1100
+ stateManager.watchState(model, 'set', {
1101
+ indexWatchRule: watchIndexRecursiveRule,
1102
+ });
1091
1103
 
1092
1104
  console.log('Changed value:');
1093
1105
  const proxyRegister: IProxyRegistry = InjectionContainer.get(
@@ -1310,7 +1322,7 @@ import {
1310
1322
  type IValueMetadata,
1311
1323
  overrideMultiInjectServices,
1312
1324
  RsXCoreInjectionTokens,
1313
- SingletonFactory,
1325
+ KeyedInstanceFactory,
1314
1326
  Type,
1315
1327
  } from '@rs-x/core';
1316
1328
  import {
@@ -1344,7 +1356,7 @@ const MyInjectTokens = {
1344
1356
  ),
1345
1357
  };
1346
1358
 
1347
- class IndexForTextDocumentxObserverManager extends SingletonFactory<
1359
+ class IndexForTextDocumentxObserverManager extends KeyedInstanceFactory<
1348
1360
  number,
1349
1361
  IIndexObserverInfo<ITextDocumentIndex>,
1350
1362
  TextDocumentIndexObserver
@@ -1402,7 +1414,7 @@ class IndexForTextDocumentxObserverManager extends SingletonFactory<
1402
1414
 
1403
1415
  // We want to ensure that for the same TextDocument we always have the same observer
1404
1416
  @Injectable()
1405
- class TextDocumentObserverManager extends SingletonFactory<
1417
+ class TextDocumentObserverManager extends KeyedInstanceFactory<
1406
1418
  TextDocument,
1407
1419
  TextDocument,
1408
1420
  TextDocumentObserver
@@ -1435,7 +1447,7 @@ class TextDocumentObserverManager extends SingletonFactory<
1435
1447
 
1436
1448
  // We want to ensure we create only one index-manager per TextDocument
1437
1449
  @Injectable()
1438
- export class TextDocumenIndexObserverManager extends SingletonFactory<
1450
+ export class TextDocumenIndexObserverManager extends KeyedInstanceFactory<
1439
1451
  TextDocument,
1440
1452
  TextDocument,
1441
1453
  IndexForTextDocumentxObserverManager
@@ -1801,7 +1813,9 @@ function testMonitorTextDocument(
1801
1813
  console.log('\n***********************************************');
1802
1814
  console.log('Start watching the whole book\n');
1803
1815
  console.log('My initial book:\n');
1804
- stateManager.watchState(model, 'myBook', watchIndexRecursiveRule);
1816
+ stateManager.watchState(model, 'myBook', {
1817
+ indexWatchRule: watchIndexRecursiveRule,
1818
+ });
1805
1819
 
1806
1820
  console.log('\nUpdate second line on the first page:\n');
1807
1821
  console.log('My book after change:\n');