angular-three 1.9.2 → 1.9.4

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.
@@ -524,13 +524,10 @@ class NgtRxStore extends RxState {
524
524
  this.cache = {};
525
525
  // set a dummy property so that initial this.get() won't return undefined
526
526
  this.set({ __ngt_dummy__: '__ngt_dummy__' });
527
- // call initialize that might be setup by derived Stores
528
- this.initialize();
529
527
  // override set so our consumers don't have to handle undefined for state that already have default values
530
528
  const originalSet = this.set.bind(this);
531
529
  Object.defineProperty(this, 'set', {
532
530
  get: () => {
533
- // Parameters type does not do well with overloads (RxState#set). So we use any[] here
534
531
  return (...args) => {
535
532
  const firstArg = args[0];
536
533
  if (is.obj(firstArg)) {
@@ -540,11 +537,24 @@ class NgtRxStore extends RxState {
540
537
  }, {});
541
538
  return originalSet(modArgs);
542
539
  }
543
- // @ts-expect-error not sure why ...args here doesn't pass tuple check
544
540
  return originalSet(...args);
545
541
  };
546
542
  },
547
543
  });
544
+ // override get to return {} if get() returns undefined
545
+ const originalGet = this.get.bind(this);
546
+ Object.defineProperty(this, 'get', {
547
+ get: () => {
548
+ return (...args) => {
549
+ if (args.length === 0) {
550
+ return originalGet() ?? {};
551
+ }
552
+ return originalGet(...args);
553
+ };
554
+ },
555
+ });
556
+ // call initialize that might be setup by derived Stores
557
+ this.initialize();
548
558
  }
549
559
  initialize() {
550
560
  return;