@signaltree/core 9.5.1 → 9.6.0
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": "@signaltree/core",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.0",
|
|
4
4
|
"description": "Reactive JSON for Angular. JSON branches, reactive leaves. No actions. No reducers. No selectors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,11 +29,6 @@
|
|
|
29
29
|
"import": "./dist/storage.js",
|
|
30
30
|
"default": "./dist/storage.js"
|
|
31
31
|
},
|
|
32
|
-
"./rxjs-interop": {
|
|
33
|
-
"types": "./src/rxjs-interop.d.ts",
|
|
34
|
-
"import": "./dist/rxjs-interop.js",
|
|
35
|
-
"default": "./dist/rxjs-interop.js"
|
|
36
|
-
},
|
|
37
32
|
"./package.json": "./package.json"
|
|
38
33
|
},
|
|
39
34
|
"peerDependencies": {
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { inject, DestroyRef, Injector, isSignal } from '@angular/core';
|
|
2
|
-
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
3
|
-
import { Subject } from '../../Subject.js';
|
|
4
|
-
import { Subscription } from '../../Subscription.js';
|
|
5
|
-
import { isObservable } from '../../isObservable.js';
|
|
6
|
-
|
|
7
|
-
function rxMethod(generator, options) {
|
|
8
|
-
const destroyRef = options?.destroyRef ?? inject(DestroyRef);
|
|
9
|
-
const injector = options?.injector ?? inject(Injector);
|
|
10
|
-
const trigger$ = new Subject();
|
|
11
|
-
const sourceSubs = new Set();
|
|
12
|
-
let isDestroyed = false;
|
|
13
|
-
const masterSub = generator(trigger$.asObservable()).pipe(takeUntilDestroyed(destroyRef)).subscribe();
|
|
14
|
-
const fn = input => {
|
|
15
|
-
if (isDestroyed) return Subscription.EMPTY;
|
|
16
|
-
if (input === undefined) {
|
|
17
|
-
trigger$.next(undefined);
|
|
18
|
-
return Subscription.EMPTY;
|
|
19
|
-
}
|
|
20
|
-
if (isSignal(input)) {
|
|
21
|
-
const sub = toObservable(input, {
|
|
22
|
-
injector
|
|
23
|
-
}).pipe(takeUntilDestroyed(destroyRef)).subscribe(value => trigger$.next(value));
|
|
24
|
-
sourceSubs.add(sub);
|
|
25
|
-
sub.add(() => sourceSubs.delete(sub));
|
|
26
|
-
return sub;
|
|
27
|
-
}
|
|
28
|
-
if (isObservable(input)) {
|
|
29
|
-
const sub = input.pipe(takeUntilDestroyed(destroyRef)).subscribe(value => trigger$.next(value));
|
|
30
|
-
sourceSubs.add(sub);
|
|
31
|
-
sub.add(() => sourceSubs.delete(sub));
|
|
32
|
-
return sub;
|
|
33
|
-
}
|
|
34
|
-
trigger$.next(input);
|
|
35
|
-
return Subscription.EMPTY;
|
|
36
|
-
};
|
|
37
|
-
const method = fn;
|
|
38
|
-
method.destroy = () => {
|
|
39
|
-
if (isDestroyed) return;
|
|
40
|
-
isDestroyed = true;
|
|
41
|
-
masterSub.unsubscribe();
|
|
42
|
-
sourceSubs.forEach(s => s.unsubscribe());
|
|
43
|
-
sourceSubs.clear();
|
|
44
|
-
trigger$.complete();
|
|
45
|
-
};
|
|
46
|
-
destroyRef.onDestroy(() => method.destroy());
|
|
47
|
-
return method;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { rxMethod };
|
package/dist/rxjs-interop.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rxMethod } from './lib/rxjs-interop/rx-method.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rxMethod, type RxMethod, type RxMethodInput, } from './rx-method';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DestroyRef, Injector, type Signal } from '@angular/core';
|
|
2
|
-
import { type Observable, Subscription } from 'rxjs';
|
|
3
|
-
export type RxMethodInput<T> = T | Signal<T> | Observable<T>;
|
|
4
|
-
export interface RxMethod<T> {
|
|
5
|
-
(...args: [T] extends [void] ? [] | [RxMethodInput<T>] : [RxMethodInput<T>]): Subscription;
|
|
6
|
-
destroy(): void;
|
|
7
|
-
}
|
|
8
|
-
export declare function rxMethod<T = void>(generator: (source$: Observable<T>) => Observable<unknown>, options?: {
|
|
9
|
-
destroyRef?: DestroyRef;
|
|
10
|
-
injector?: Injector;
|
|
11
|
-
}): RxMethod<T>;
|
package/src/rxjs-interop.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rxMethod, type RxMethod, type RxMethodInput, } from './lib/rxjs-interop';
|