@fozy-labs/rx-toolkit 0.4.9 → 0.4.10
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/query/core/Opertation/Operation.js +1 -1
- package/dist/query/core/Resource/Resource.js +1 -1
- package/dist/query/types/Operation.types.d.ts +4 -0
- package/dist/query/types/Resource.types.d.ts +4 -0
- package/dist/signals/base/Computed.d.ts +4 -1
- package/dist/signals/base/Computed.js +7 -4
- package/dist/signals/base/Effect.d.ts +4 -1
- package/dist/signals/base/Effect.js +8 -5
- package/dist/signals/base/Signal.d.ts +7 -3
- package/dist/signals/base/Signal.js +8 -2
- package/docs/release/README.md +7 -0
- package/package.json +1 -1
|
@@ -59,7 +59,7 @@ export class Operation {
|
|
|
59
59
|
constructor(_options) {
|
|
60
60
|
this._options = _options;
|
|
61
61
|
this._queriesCache = new QueriesCache(this._options.cacheLifetime ?? this._DEFAULT_CACHE_LIFETIME);
|
|
62
|
-
this._hooks = new QueriesLifetimeHooks(_options, 'Operation');
|
|
62
|
+
this._hooks = new QueriesLifetimeHooks(_options, _options.devtoolsName ?? 'Operation');
|
|
63
63
|
this._createLinks();
|
|
64
64
|
}
|
|
65
65
|
_createLinks() {
|
|
@@ -108,7 +108,7 @@ export class Resource {
|
|
|
108
108
|
_DEFAULT_CACHE_LIFETIME = 60_000;
|
|
109
109
|
constructor(_options) {
|
|
110
110
|
this._options = _options;
|
|
111
|
-
this._hooks = new QueriesLifetimeHooks(_options, 'Resource');
|
|
111
|
+
this._hooks = new QueriesLifetimeHooks(_options, _options.devtoolsName ?? 'Resource');
|
|
112
112
|
this._queriesCache = new QueriesCache(_options.cacheLifetime ?? this._DEFAULT_CACHE_LIFETIME);
|
|
113
113
|
}
|
|
114
114
|
createAgent = () => {
|
|
@@ -33,6 +33,10 @@ export type OperationCreateOptions<D extends OperationDefinition> = {
|
|
|
33
33
|
* - завершение запроса с результатом или ошибкой
|
|
34
34
|
*/
|
|
35
35
|
onQueryStarted?: OnQueryStarted<D["Args"], D["Result"]>;
|
|
36
|
+
/**
|
|
37
|
+
* Имя для инструментов разработчика (DevTools)
|
|
38
|
+
*/
|
|
39
|
+
devtoolsName?: string | undefined | null;
|
|
36
40
|
};
|
|
37
41
|
/**
|
|
38
42
|
* Настройки связи операции с ресурсом
|
|
@@ -31,6 +31,10 @@ export type ResourceCreateOptions<D extends ResourceDefinition> = {
|
|
|
31
31
|
* - завершение запроса с результатом или ошибкой
|
|
32
32
|
*/
|
|
33
33
|
onQueryStarted?: OnQueryStarted<D["Args"], D["Result"]>;
|
|
34
|
+
/**
|
|
35
|
+
* Имя ресурса в инструментах разработчика
|
|
36
|
+
*/
|
|
37
|
+
devtoolsName?: string | undefined | null;
|
|
34
38
|
};
|
|
35
39
|
/**
|
|
36
40
|
* Определение типов ресурса
|
|
@@ -8,6 +8,9 @@ export declare class Computed<T> extends Signal<T> implements SubscriptionLike,
|
|
|
8
8
|
disableDevtools?: boolean;
|
|
9
9
|
devtoolsName?: string;
|
|
10
10
|
});
|
|
11
|
-
unsubscribe(): void;
|
|
12
11
|
complete(): void;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use 'complete()' instead
|
|
14
|
+
*/
|
|
15
|
+
unsubscribe(): void;
|
|
13
16
|
}
|
|
@@ -21,13 +21,16 @@ export class Computed extends Signal {
|
|
|
21
21
|
});
|
|
22
22
|
this._effect = effect;
|
|
23
23
|
}
|
|
24
|
-
unsubscribe() {
|
|
25
|
-
this.complete();
|
|
26
|
-
}
|
|
27
24
|
complete() {
|
|
28
25
|
if (this.closed)
|
|
29
26
|
return;
|
|
30
|
-
this._effect.
|
|
27
|
+
this._effect.complete();
|
|
31
28
|
super.complete();
|
|
32
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated use 'complete()' instead
|
|
32
|
+
*/
|
|
33
|
+
unsubscribe() {
|
|
34
|
+
this.complete();
|
|
35
|
+
}
|
|
33
36
|
}
|
|
@@ -9,6 +9,9 @@ export declare class Effect implements SubscriptionLike {
|
|
|
9
9
|
* Выполняет функцию в tracked-контексте, подписываясь на Tracker.
|
|
10
10
|
*/
|
|
11
11
|
private _runInTrackedContext;
|
|
12
|
-
unsubscribe(): void;
|
|
13
12
|
complete(): void;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `complete()` method instead.
|
|
15
|
+
*/
|
|
16
|
+
unsubscribe(): void;
|
|
14
17
|
}
|
|
@@ -41,11 +41,11 @@ export class Effect {
|
|
|
41
41
|
}));
|
|
42
42
|
},
|
|
43
43
|
complete: () => {
|
|
44
|
-
this.
|
|
44
|
+
this.complete();
|
|
45
45
|
},
|
|
46
46
|
error: (err) => {
|
|
47
47
|
console.error(err);
|
|
48
|
-
this.
|
|
48
|
+
this.complete();
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
effectFn((fn) => {
|
|
@@ -56,9 +56,6 @@ export class Effect {
|
|
|
56
56
|
scheduler = Batcher.scheduler(this._rang);
|
|
57
57
|
prevSubscriptions?.forEach((sub) => sub.unsubscribe());
|
|
58
58
|
}
|
|
59
|
-
unsubscribe() {
|
|
60
|
-
this.complete();
|
|
61
|
-
}
|
|
62
59
|
complete() {
|
|
63
60
|
if (this.closed)
|
|
64
61
|
return;
|
|
@@ -66,4 +63,10 @@ export class Effect {
|
|
|
66
63
|
this._subscriptions.forEach((sub) => sub.unsubscribe());
|
|
67
64
|
this._onComplete?.();
|
|
68
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Use `complete()` method instead.
|
|
68
|
+
*/
|
|
69
|
+
unsubscribe() {
|
|
70
|
+
this.complete();
|
|
71
|
+
}
|
|
69
72
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BehaviorSubject, Observable } from "rxjs";
|
|
1
|
+
import { BehaviorSubject, Observable, SubscriptionLike } from "rxjs";
|
|
2
2
|
import type { ReadableSignalLike, SignalLike, UnaryFunction } from "./types";
|
|
3
3
|
type SignalOptions = {
|
|
4
4
|
disableDevtools?: boolean;
|
|
5
5
|
devtoolsName?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare class Signal<T> extends BehaviorSubject<T> implements SignalLike<T> {
|
|
7
|
+
export declare class Signal<T> extends BehaviorSubject<T> implements SubscriptionLike, SignalLike<T> {
|
|
8
8
|
private readonly _devtools;
|
|
9
9
|
protected _rang: number;
|
|
10
10
|
constructor(initialValue: T, options?: SignalOptions);
|
|
@@ -26,6 +26,11 @@ export declare class Signal<T> extends BehaviorSubject<T> implements SignalLike<
|
|
|
26
26
|
*/
|
|
27
27
|
set(value: T): void;
|
|
28
28
|
complete(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated use `complete()` instead.
|
|
31
|
+
*/
|
|
32
|
+
unsubscribe(): void;
|
|
33
|
+
asReadonly(): ReadableSignalLike<T>;
|
|
29
34
|
pipe(): Signal<T>;
|
|
30
35
|
pipe<A extends Observable<any>>(op1: UnaryFunction<ReadableSignalLike<T>, A>): A;
|
|
31
36
|
pipe<A extends Observable<any>, B extends Observable<any>>(op1: UnaryFunction<Signal<T>, A>, op2: UnaryFunction<A, B>): B;
|
|
@@ -37,6 +42,5 @@ export declare class Signal<T> extends BehaviorSubject<T> implements SignalLike<
|
|
|
37
42
|
pipe<A extends Observable<any>, B extends Observable<any>, C extends Observable<any>, D extends Observable<any>, E extends Observable<any>, F extends Observable<any>, G extends Observable<any>, H extends Observable<any>>(op1: UnaryFunction<Signal<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>): H;
|
|
38
43
|
pipe<A extends Observable<any>, B extends Observable<any>, C extends Observable<any>, D extends Observable<any>, E extends Observable<any>, F extends Observable<any>, G extends Observable<any>, H extends Observable<any>, I extends Observable<any>>(op1: UnaryFunction<Signal<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>): I;
|
|
39
44
|
pipe<A extends Observable<any>, B extends Observable<any>, C extends Observable<any>, D extends Observable<any>, E extends Observable<any>, F extends Observable<any>, G extends Observable<any>, H extends Observable<any>, I extends Observable<any>>(op1: UnaryFunction<Signal<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>, ...operations: UnaryFunction<Observable<any>, Observable<any>>[]): Observable<unknown>;
|
|
40
|
-
asReadonly(): ReadableSignalLike<T>;
|
|
41
45
|
}
|
|
42
46
|
export {};
|
|
@@ -56,12 +56,18 @@ export class Signal extends BehaviorSubject {
|
|
|
56
56
|
this._devtools?.('$COMPLETE');
|
|
57
57
|
super.complete();
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated use `complete()` instead.
|
|
61
|
+
*/
|
|
62
|
+
unsubscribe() {
|
|
63
|
+
this.complete();
|
|
61
64
|
}
|
|
62
65
|
asReadonly() {
|
|
63
66
|
return this;
|
|
64
67
|
}
|
|
68
|
+
pipe(...operations) {
|
|
69
|
+
return operations.reduce(pipeReducer, this);
|
|
70
|
+
}
|
|
65
71
|
}
|
|
66
72
|
function pipeReducer(prev, fn) {
|
|
67
73
|
return fn(prev);
|