@tstdl/base 0.91.9 → 0.91.11

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.
@@ -1,5 +1,5 @@
1
1
  import { BehaviorSubject, Subject, distinctUntilChanged, filter, firstValueFrom, map, startWith } from 'rxjs';
2
- import { getCurrentSignalsInjector, toLazySignal, untracked } from '../signals/index.js';
2
+ import { toLazySignal, untracked } from '../signals/index.js';
3
3
  import { lazyProperty } from '../utils/object/lazy-property.js';
4
4
  export class Collection {
5
5
  sizeSubject = new BehaviorSubject(0);
@@ -50,11 +50,10 @@ export class Collection {
50
50
  return this.size > 0;
51
51
  }
52
52
  constructor() {
53
- const injector = getCurrentSignalsInjector();
54
- lazyProperty(this, '$size', () => untracked(() => toLazySignal(this.size$, { injector, requireSync: true })));
55
- lazyProperty(this, '$observe', () => untracked(() => toLazySignal(this.observe$, { injector, requireSync: true, equal: () => false })));
56
- lazyProperty(this, '$isEmpty', () => untracked(() => toLazySignal(this.isEmpty$, { injector, requireSync: true })));
57
- lazyProperty(this, '$hasItems', () => untracked(() => toLazySignal(this.hasItems$, { injector, requireSync: true })));
53
+ lazyProperty(this, '$size', () => untracked(() => toLazySignal(this.size$, { requireSync: true })));
54
+ lazyProperty(this, '$observe', () => untracked(() => toLazySignal(this.observe$, { requireSync: true, equal: () => false })));
55
+ lazyProperty(this, '$isEmpty', () => untracked(() => toLazySignal(this.isEmpty$, { requireSync: true })));
56
+ lazyProperty(this, '$hasItems', () => untracked(() => toLazySignal(this.hasItems$, { requireSync: true })));
58
57
  }
59
58
  [Symbol.iterator]() {
60
59
  return this.items();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.91.9",
3
+ "version": "0.91.11",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,7 +16,7 @@ export function toObservable(source, options) {
16
16
  catch (error) {
17
17
  untracked(() => subscriber.error(error));
18
18
  }
19
- }, { allowSignalWrites: true, injector: options?.injector });
19
+ }, { allowSignalWrites: true, injector: options?.injector, manualCleanup: true });
20
20
  return () => effectRef.destroy();
21
21
  });
22
22
  }
@@ -1,8 +1,14 @@
1
- import { computed, getCurrentSignalsInjector, runInSignalsInjectionContext, toSignal, untracked } from './api.js';
1
+ import { Subject, takeUntil } from 'rxjs';
2
+ import { registerFinalization } from '../memory/finalization.js';
3
+ import { computed, toSignal, untracked } from './api.js';
2
4
  export const toLazySignal = function toLazySignal(source, options) {
3
- const injector = getCurrentSignalsInjector();
5
+ const finalize$ = new Subject();
4
6
  let computation = () => {
5
- const signal = untracked(() => runInSignalsInjectionContext(injector, () => toSignal(source, { ...options }))); // eslint-disable-line @typescript-eslint/no-unsafe-argument
7
+ const signal = untracked(() => toSignal(source.pipe(takeUntil(finalize$)), { ...options })); // eslint-disable-line @typescript-eslint/no-unsafe-argument
8
+ registerFinalization(signal, () => {
9
+ finalize$.next();
10
+ finalize$.complete();
11
+ });
6
12
  const value = signal();
7
13
  computation = signal;
8
14
  return value;