@fozy-labs/rx-toolkit 0.4.13 → 0.4.14

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.
@@ -7,6 +7,7 @@ export declare class ResourceAgent<D extends ResourceDefinition> implements Reso
7
7
  state$: Computed<{
8
8
  isInitiated: boolean;
9
9
  isLoading: boolean;
10
+ isInitialLoading: boolean;
10
11
  isDone: boolean;
11
12
  isSuccess: boolean;
12
13
  isError: boolean;
@@ -18,6 +19,7 @@ export declare class ResourceAgent<D extends ResourceDefinition> implements Reso
18
19
  } | {
19
20
  isInitiated: boolean;
20
21
  isLoading: boolean;
22
+ isInitialLoading: boolean;
21
23
  isDone: boolean;
22
24
  isSuccess: boolean;
23
25
  isError: boolean;
@@ -17,6 +17,7 @@ export class ResourceAgent {
17
17
  return {
18
18
  isInitiated: false,
19
19
  isLoading: false,
20
+ isInitialLoading: false,
20
21
  isDone: false,
21
22
  isSuccess: false,
22
23
  isError: false,
@@ -32,6 +33,7 @@ export class ResourceAgent {
32
33
  return {
33
34
  isInitiated: currState.isInitiated || !!prevState,
34
35
  isLoading: currState.isLoading,
36
+ isInitialLoading: currState.isLoading && !currState.isDone && !prevState?.isDone,
35
37
  isDone: currState.isDone,
36
38
  isSuccess: currState.isSuccess,
37
39
  isError: currState.isError,
@@ -76,8 +76,10 @@ export type ResourceAgentInstance<D extends ResourceDefinition> = {
76
76
  export type ResourceQueryState<D extends ResourceDefinition> = {
77
77
  /** Инициализирован ли хотя бы один запрос */
78
78
  isInitiated: boolean;
79
- /** Первая загрузка */
79
+ /** Загрузка */
80
80
  isLoading: boolean;
81
+ /** Первая загрузка */
82
+ isInitialLoading: boolean;
81
83
  /** Завершен ли запрос */
82
84
  isDone: boolean;
83
85
  /** Успешно ли завершен последний запрос (false по умолчанию) */
@@ -2,6 +2,7 @@ import { SubscriptionLike } from "rxjs";
2
2
  export declare class Effect implements SubscriptionLike {
3
3
  private _onComplete?;
4
4
  private _subscriptions;
5
+ protected readonly _scopeDestroyedSub: import("rxjs").Subscription | undefined;
5
6
  closed: boolean;
6
7
  _rang: number;
7
8
  constructor(effectFn: (ctx: (fn: () => void) => void) => void, _onComplete?: (() => void) | undefined);
@@ -1,7 +1,11 @@
1
1
  import { Batcher, Tracker } from "../base";
2
+ import { SharedOptions } from "../../common/options/SharedOptions";
2
3
  export class Effect {
3
4
  _onComplete;
4
5
  _subscriptions = [];
6
+ _scopeDestroyedSub = SharedOptions.getScopeDestroyed$()?.subscribe(() => {
7
+ this.complete();
8
+ });
5
9
  closed = false;
6
10
  _rang = 0;
7
11
  constructor(effectFn, _onComplete) {
@@ -60,6 +64,7 @@ export class Effect {
60
64
  return;
61
65
  this.closed = true;
62
66
  this._subscriptions.forEach((sub) => sub.unsubscribe());
67
+ this._scopeDestroyedSub?.unsubscribe();
63
68
  this._onComplete?.();
64
69
  }
65
70
  /**
@@ -4,6 +4,7 @@ import { StateDevtoolsOptions } from "../../common/devtools";
4
4
  export declare class Signal<T> extends BehaviorSubject<T> implements SubscriptionLike, SignalLike<T> {
5
5
  private readonly _stateDevtools;
6
6
  protected _rang: number;
7
+ protected readonly _scopeDestroyedSub: import("rxjs").Subscription | undefined;
7
8
  constructor(initialValue: T, options?: StateDevtoolsOptions);
8
9
  protected _onChange(value: T): void;
9
10
  get value(): T;
@@ -1,8 +1,12 @@
1
1
  import { BehaviorSubject } from "rxjs";
2
2
  import { Batcher, Tracker, Devtools } from "../base";
3
+ import { SharedOptions } from "../../common/options/SharedOptions";
3
4
  export class Signal extends BehaviorSubject {
4
5
  _stateDevtools;
5
6
  _rang = 0;
7
+ _scopeDestroyedSub = SharedOptions.getScopeDestroyed$()?.subscribe(() => {
8
+ this.complete();
9
+ });
6
10
  constructor(initialValue, options) {
7
11
  super(initialValue);
8
12
  this._stateDevtools = Devtools.createState(initialValue, {
@@ -49,6 +53,7 @@ export class Signal extends BehaviorSubject {
49
53
  }
50
54
  complete() {
51
55
  this._stateDevtools?.('$COMPLETE');
56
+ this._scopeDestroyedSub?.unsubscribe();
52
57
  super.complete();
53
58
  }
54
59
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fozy-labs/rx-toolkit",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",