@fozy-labs/rx-toolkit 0.4.2 → 0.4.3

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.
Files changed (69) hide show
  1. package/README.md +4 -5
  2. package/dist/{devtools → common/devtools}/combineDevtools.d.ts +1 -1
  3. package/dist/{devtools → common/devtools}/index.d.ts +1 -0
  4. package/dist/{devtools → common/devtools}/index.js +1 -0
  5. package/dist/common/devtools/reduxDevtools.d.ts +2 -0
  6. package/dist/{devtools → common/devtools}/reduxDevtools.js +1 -1
  7. package/dist/{query/api → common/options}/DefaultOptions.d.ts +1 -1
  8. package/dist/{query/api → common/options}/DefaultOptions.js +1 -1
  9. package/dist/{query/core → common/options}/SharedOptions.d.ts +1 -1
  10. package/dist/common/options/index.d.ts +1 -0
  11. package/dist/common/options/index.js +1 -0
  12. package/dist/{react-hooks → common/react}/index.d.ts +2 -3
  13. package/dist/{react-hooks → common/react}/index.js +2 -3
  14. package/dist/{react-hooks → common/react}/useObservable.js +2 -2
  15. package/dist/{react-hooks → common/react}/useSyncObservable.js +2 -1
  16. package/dist/index.d.ts +3 -2
  17. package/dist/index.js +3 -2
  18. package/dist/query/api/createOperation.d.ts +1 -5
  19. package/dist/query/api/createOperation.js +0 -4
  20. package/dist/query/api/createResource.d.ts +1 -1
  21. package/dist/query/core/Opertation/Operation.d.ts +2 -3
  22. package/dist/query/core/Opertation/Operation.js +1 -1
  23. package/dist/query/core/Opertation/OperationAgent.d.ts +2 -2
  24. package/dist/query/core/QueriesCache.js +2 -2
  25. package/dist/query/core/Resource/Resource.d.ts +2 -2
  26. package/dist/query/core/Resource/Resource.js +2 -2
  27. package/dist/query/core/Resource/ResourceAgent.d.ts +1 -1
  28. package/dist/query/core/Resource/ResourceRef.d.ts +1 -1
  29. package/dist/query/index.d.ts +0 -1
  30. package/dist/query/index.js +0 -1
  31. package/dist/query/lib/IndirectMap.js +1 -1
  32. package/dist/query/react/useOperationAgent.d.ts +1 -2
  33. package/dist/query/react/useOperationAgent.js +2 -1
  34. package/dist/query/react/useResourceAgent.d.ts +2 -3
  35. package/dist/query/react/useResourceAgent.js +4 -3
  36. package/dist/query/react/useResourceRef.d.ts +1 -2
  37. package/dist/query/react/useResourceRef.js +1 -1
  38. package/dist/query/types/Operation.types.d.ts +1 -1
  39. package/dist/query/types/Resource.types.d.ts +2 -2
  40. package/dist/query/types/index.d.ts +3 -0
  41. package/dist/query/types/index.js +3 -0
  42. package/dist/signals/base/ReadonlySignal.d.ts +2 -1
  43. package/dist/signals/base/ReadonlySignal.js +19 -3
  44. package/dist/signals/base/Signal.d.ts +2 -2
  45. package/dist/signals/base/Signal.js +1 -1
  46. package/dist/signals/base/Tracker.d.ts +0 -4
  47. package/dist/signals/base/Tracker.js +0 -6
  48. package/dist/signals/base/types.d.ts +9 -0
  49. package/dist/signals/index.d.ts +1 -0
  50. package/dist/signals/index.js +1 -0
  51. package/dist/signals/react/index.d.ts +1 -0
  52. package/dist/signals/react/index.js +1 -0
  53. package/dist/{react-hooks → signals/react}/useSignal.d.ts +1 -1
  54. package/dist/{react-hooks → signals/react}/useSignal.js +1 -1
  55. package/docs/signals/README.md +1 -1
  56. package/package.json +1 -1
  57. package/dist/devtools/reduxDevtools.d.ts +0 -2
  58. package/dist/query/api/createSubResource.d.ts +0 -0
  59. package/dist/query/api/createSubResource.js +0 -1
  60. /package/dist/{devtools → common/devtools}/combineDevtools.js +0 -0
  61. /package/dist/{query/types/devtools.d.ts → common/devtools/types.d.ts} +0 -0
  62. /package/dist/{query/types/devtools.js → common/devtools/types.js} +0 -0
  63. /package/dist/{query/core → common/options}/SharedOptions.js +0 -0
  64. /package/dist/{react-hooks → common/react}/useConstant.d.ts +0 -0
  65. /package/dist/{react-hooks → common/react}/useConstant.js +0 -0
  66. /package/dist/{react-hooks → common/react}/useEventHandler.d.ts +0 -0
  67. /package/dist/{react-hooks → common/react}/useEventHandler.js +0 -0
  68. /package/dist/{react-hooks → common/react}/useObservable.d.ts +0 -0
  69. /package/dist/{react-hooks → common/react}/useSyncObservable.d.ts +0 -0
package/README.md CHANGED
@@ -41,11 +41,11 @@ RxToolkit решает эти проблемы, предоставляя сво
41
41
 
42
42
  ###### Создаем сигнал
43
43
  ```typescript
44
- // Описываете логику в обычном JavaScript
44
+ // Описываем логику в обычном JavaScript
45
45
  const store = {
46
- count$: new Signal(0),
47
- doubled$: new Computed(() => store.count$.value * 2),
48
- increment: () => store.count$.next(store.count$.value + 1)
46
+ count$: new Signal(0),
47
+ doubled$: new Computed(() => store.count$.value * 2),
48
+ increment: () => store.count$.value++,
49
49
  };
50
50
  ```
51
51
 
@@ -71,7 +71,6 @@ $: count = store.count$;
71
71
 
72
72
  ```typescript
73
73
  // Создаем Observable
74
-
75
74
  const clicker$ = fromEvent(document, 'click').pipe(
76
75
  debounceTime(300),
77
76
  scan(count => count + 1, 0),
@@ -1,2 +1,2 @@
1
- import { DevtoolsLike } from "../query/types/devtools";
1
+ import { DevtoolsLike } from "./types";
2
2
  export declare function combineDevtools(...devtools: DevtoolsLike[]): DevtoolsLike;
@@ -1,2 +1,3 @@
1
1
  export * from './reduxDevtools';
2
2
  export * from './combineDevtools';
3
+ export * from './types';
@@ -1,2 +1,3 @@
1
1
  export * from './reduxDevtools';
2
2
  export * from './combineDevtools';
3
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ import { DevtoolsLike } from "./types";
2
+ export declare function reduxDevtools(): DevtoolsLike;
@@ -1,4 +1,4 @@
1
- import { Batcher } from "../signals";
1
+ import { Batcher } from "../../signals";
2
2
  export function reduxDevtools() {
3
3
  let state = {};
4
4
  // @ts-ignore
@@ -1,4 +1,4 @@
1
- import { DevtoolsLike } from "../../query/types/devtools";
1
+ import type { DevtoolsLike } from "../../common/devtools";
2
2
  type Update = Partial<{
3
3
  DEVTOOLS: DevtoolsLike | null;
4
4
  onError: (error: unknown) => void;
@@ -1,4 +1,4 @@
1
- import { SharedOptions } from "../../query/core/SharedOptions";
1
+ import { SharedOptions } from "./SharedOptions";
2
2
  export class DefaultOptions {
3
3
  static update(part) {
4
4
  if (part.DEVTOOLS !== undefined)
@@ -1,4 +1,4 @@
1
- import { DevtoolsLike } from "../../query/types/devtools";
1
+ import { DevtoolsLike } from "../../common/devtools";
2
2
  export declare class SharedOptions {
3
3
  static DEVTOOLS: DevtoolsLike | null;
4
4
  static onError: ((error: unknown) => void) | null;
@@ -0,0 +1 @@
1
+ export * from './DefaultOptions';
@@ -0,0 +1 @@
1
+ export * from './DefaultOptions';
@@ -1,5 +1,4 @@
1
- export * from './useSignal';
1
+ export * from './useConstant';
2
+ export * from './useEventHandler';
2
3
  export * from './useObservable';
3
4
  export * from './useSyncObservable';
4
- export * from './useEventHandler';
5
- export * from './useConstant';
@@ -1,5 +1,4 @@
1
- export * from './useSignal';
1
+ export * from './useConstant';
2
+ export * from './useEventHandler';
2
3
  export * from './useObservable';
3
4
  export * from './useSyncObservable';
4
- export * from './useEventHandler';
5
- export * from './useConstant';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { useEventHandler } from "../react-hooks/useEventHandler";
3
2
  import { BehaviorSubject } from 'rxjs';
4
- import { useConstant } from "../react-hooks/useConstant";
3
+ import { useConstant } from "./useConstant";
4
+ import { useEventHandler } from "./useEventHandler";
5
5
  const NONE = Symbol('NONE');
6
6
  /**
7
7
  * Hook for automatically subscribing and unsubscribing from an Observable.
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { BehaviorSubject } from 'rxjs';
3
- import { useConstant, useEventHandler } from "../react-hooks";
3
+ import { useConstant } from "./useConstant";
4
+ import { useEventHandler } from "./useEventHandler";
4
5
  const NONE = Symbol('NONE');
5
6
  /**
6
7
  * Hook for automatically subscribing and unsubscribing from an Observable.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
+ export * from './common/devtools';
2
+ export * from './common/options';
3
+ export * from './common/react';
1
4
  export * from './query';
2
5
  export * from './signals';
3
- export * from './react-hooks';
4
- export * from './devtools';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
+ export * from './common/devtools';
2
+ export * from './common/options';
3
+ export * from './common/react';
1
4
  export * from './query';
2
5
  export * from './signals';
3
- export * from './react-hooks';
4
- export * from './devtools';
@@ -1,7 +1,3 @@
1
- import type { OperationCreateOptions, OperationDefinition } from "../../query/types/Operation.types";
1
+ import type { OperationCreateOptions, OperationDefinition } from "../../query/types";
2
2
  import { Operation } from "../../query/core/Opertation/Operation";
3
3
  export declare const createOperation: <ARGS, RESULT, SELECTED = never>(options: OperationCreateOptions<OperationDefinition<ARGS, RESULT, SELECTED>>) => Operation<OperationDefinition<ARGS, RESULT, SELECTED>>;
4
- /**
5
- * @deprecated Use `createOperation` instead.
6
- */
7
- export declare const createMutationApi: <ARGS, RESULT, SELECTED = never>(options: OperationCreateOptions<OperationDefinition<ARGS, RESULT, SELECTED>>) => Operation<OperationDefinition<ARGS, RESULT, SELECTED>>;
@@ -1,6 +1,2 @@
1
1
  import { Operation } from "../../query/core/Opertation/Operation";
2
2
  export const createOperation = ((options) => new Operation(options));
3
- /**
4
- * @deprecated Use `createOperation` instead.
5
- */
6
- export const createMutationApi = createOperation;
@@ -1,3 +1,3 @@
1
- import type { ResourceCreateOptions, ResourceDefinition } from "../../query/types/Resource.types";
1
+ import type { ResourceCreateOptions, ResourceDefinition } from "../../query/types";
2
2
  import { Resource } from "../../query/core/Resource/Resource";
3
3
  export declare const createResource: <ARGS, RESULT, SELECTED = never>(options: ResourceCreateOptions<ResourceDefinition<ARGS, RESULT, SELECTED>>) => Resource<ResourceDefinition<ARGS, RESULT, SELECTED>>;
@@ -1,6 +1,5 @@
1
- import { ReactiveCache } from "../../../query/lib/ReactiveCache";
2
- import { FallbackOnNever } from "../../../query/types/shared.types";
3
- import { OperationCreateOptions, OperationDefinition, OperationInstance } from "../../../query/types/Operation.types";
1
+ import type { ReactiveCache } from "../../../query/lib/ReactiveCache";
2
+ import type { FallbackOnNever, OperationCreateOptions, OperationDefinition, OperationInstance } from "../../../query/types";
4
3
  import { QueriesCache } from "../QueriesCache";
5
4
  import { OperationAgent } from "./OperationAgent";
6
5
  export type CoreOperationQueryState<D extends OperationDefinition> = {
@@ -1,5 +1,5 @@
1
+ import { SharedOptions } from "../../../common/options/SharedOptions";
1
2
  import { QueriesCache } from "../QueriesCache";
2
- import { SharedOptions } from "../SharedOptions";
3
3
  import { OperationAgent } from "./OperationAgent";
4
4
  class OperationQueryState {
5
5
  static create() {
@@ -1,4 +1,4 @@
1
- import { OperationAgentInstanse, OperationDefinition } from "../../../query/types/Operation.types";
1
+ import { OperationAgentInstanse, OperationDefinition } from "../../../query/types";
2
2
  import { Computed } from "../../../signals";
3
3
  import type { Operation } from "./Operation";
4
4
  export declare class OperationAgent<D extends OperationDefinition> implements OperationAgentInstanse<D> {
@@ -10,7 +10,7 @@ export declare class OperationAgent<D extends OperationDefinition> implements Op
10
10
  isSuccess: boolean;
11
11
  isError: boolean;
12
12
  error: {} | undefined;
13
- data: NonNullable<import("../../types/shared.types").FallbackOnNever<D["Selected"], D["Result"]>> | undefined;
13
+ data: NonNullable<import("../../../query/types").FallbackOnNever<D["Selected"], D["Result"]>> | undefined;
14
14
  args: D["Args"];
15
15
  }>;
16
16
  constructor(_operation: Operation<D>);
@@ -1,7 +1,7 @@
1
+ import { SharedOptions } from "../../common/options/SharedOptions";
2
+ import { Indexer } from "../../signals/base/Indexer";
1
3
  import { IndirectMap } from "../../query/lib/IndirectMap";
2
4
  import { ReactiveCache } from "../../query/lib/ReactiveCache";
3
- import { Indexer } from "../../signals/base/Indexer";
4
- import { SharedOptions } from "./SharedOptions";
5
5
  export class QueriesCache {
6
6
  _logname;
7
7
  _cache = new IndirectMap();
@@ -1,6 +1,6 @@
1
1
  import { ReactiveCache } from "../../../query/lib/ReactiveCache";
2
- import type { ResourceCreateOptions, ResourceDefinition, ResourceInstance, ResourceRefInstanse, ResourceTransaction } from "../../../query/types/Resource.types";
3
- import { QueriesCache } from "../QueriesCache";
2
+ import type { ResourceCreateOptions, ResourceDefinition, ResourceInstance, ResourceRefInstanse, ResourceTransaction } from "../../../query/types";
3
+ import { QueriesCache } from "../../../query/core/QueriesCache";
4
4
  import { ResourceAgent } from "./ResourceAgent";
5
5
  export type CoreResourceQueryState<D extends ResourceDefinition> = {
6
6
  transactions: ResourceTransaction[] | null;
@@ -1,5 +1,5 @@
1
- import { QueriesCache } from "../QueriesCache";
2
- import { SharedOptions } from "../SharedOptions";
1
+ import { SharedOptions } from "../../../common/options/SharedOptions";
2
+ import { QueriesCache } from "../../../query/core/QueriesCache";
3
3
  import { ResourceAgent } from "./ResourceAgent";
4
4
  import { ResourceRef } from "./ResourceRef";
5
5
  class ResourceQueryState {
@@ -1,5 +1,5 @@
1
1
  import { Computed } from "../../../signals";
2
- import { ResourceAgentInstance, ResourceDefinition } from "../../../query/types/Resource.types";
2
+ import { ResourceAgentInstance, ResourceDefinition } from "../../../query/types";
3
3
  import type { Resource } from "./Resource";
4
4
  export declare class ResourceAgent<D extends ResourceDefinition> implements ResourceAgentInstance<D> {
5
5
  private _resource;
@@ -1,5 +1,5 @@
1
+ import { ResourceDefinition, ResourceRefInstanse, ResourceTransaction } from "../../../query/types";
1
2
  import { Resource } from "./Resource";
2
- import { ResourceDefinition, ResourceRefInstanse, ResourceTransaction } from "../../types/Resource.types";
3
3
  export declare class ResourceRef<D extends ResourceDefinition> implements ResourceRefInstanse<D> {
4
4
  private readonly _resource;
5
5
  private readonly _args;
@@ -1,6 +1,5 @@
1
1
  export * from './api/createResource';
2
2
  export * from './api/createOperation';
3
- export * from './api/DefaultOptions';
4
3
  export * from './SKIP_TOKEN';
5
4
  export * from './react/useResourceAgent';
6
5
  export * from './react/useResourceRef';
@@ -1,6 +1,5 @@
1
1
  export * from './api/createResource';
2
2
  export * from './api/createOperation';
3
- export * from './api/DefaultOptions';
4
3
  export * from './SKIP_TOKEN';
5
4
  export * from './react/useResourceAgent';
6
5
  export * from './react/useResourceRef';
@@ -1,4 +1,4 @@
1
- import { shallowEqual } from "../../query/lib/shallowEqual";
1
+ import { shallowEqual } from "./shallowEqual";
2
2
  export class IndirectMap {
3
3
  _compareObjectsFn;
4
4
  _compareCache = new WeakMap();
@@ -1,5 +1,4 @@
1
- import { OperationAgentInstanse, OperationDefinition, OperationQueryState } from "../types/Operation.types";
2
- import { Prettify } from "../types/shared.types";
1
+ import type { Prettify, OperationAgentInstanse, OperationDefinition, OperationQueryState } from "../../query/types";
3
2
  type WithAgent<D extends OperationDefinition> = {
4
3
  createAgent: () => OperationAgentInstanse<D>;
5
4
  };
@@ -1,4 +1,5 @@
1
- import { useConstant, useEventHandler, useSignal } from "../../react-hooks";
1
+ import { useConstant, useEventHandler } from "../../common/react";
2
+ import { useSignal } from "../../signals/react";
2
3
  export function useOperationAgent(op) {
3
4
  const agent = useConstant(() => op.createAgent());
4
5
  const state = useSignal(agent.state$);
@@ -1,6 +1,5 @@
1
- import { ResourceAgentInstance, ResourceDefinition, ResourceQueryState } from "../types/Resource.types";
2
- import { Prettify } from "../types/shared.types";
3
- import { SKIP } from "../SKIP_TOKEN";
1
+ import { Prettify, ResourceAgentInstance, ResourceDefinition, ResourceQueryState } from "../../query/types";
2
+ import { SKIP } from "../../query/SKIP_TOKEN";
4
3
  type WithAgent<D extends ResourceDefinition> = {
5
4
  createAgent: () => ResourceAgentInstance<D>;
6
5
  };
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
- import { useConstant, useSignal } from "../../react-hooks";
3
- import { shallowEqual } from "../lib/shallowEqual";
4
- import { SKIP } from "../SKIP_TOKEN";
2
+ import { useConstant } from "../../common/react";
3
+ import { useSignal } from "../../signals/react";
4
+ import { shallowEqual } from "../../query/lib/shallowEqual";
5
+ import { SKIP } from "../../query/SKIP_TOKEN";
5
6
  export function useResourceAgent(res, ...argss) {
6
7
  const args = (argss[0] === SKIP ? SKIP : argss[0]);
7
8
  const agent = useConstant(() => {
@@ -1,6 +1,5 @@
1
1
  import { SKIP } from "../../query/SKIP_TOKEN";
2
- import { ResourceDefinition, ResourceInstance, ResourceRefInstanse } from "../../query/types/Resource.types";
3
- import { Prettify } from "../../query/types/shared.types";
2
+ import type { Prettify, ResourceDefinition, ResourceInstance, ResourceRefInstanse } from "../../query/types";
4
3
  type Result<D extends ResourceDefinition> = Prettify<ResourceRefInstanse<D>> | null;
5
4
  export declare function useResourceRef<D extends ResourceDefinition>(res: ResourceInstance<D>, ...argss: D['Args'] extends void ? [] | [typeof SKIP] : [D['Args'] | typeof SKIP]): Result<D>;
6
5
  export {};
@@ -1,5 +1,5 @@
1
- import { SKIP } from "../../query/SKIP_TOKEN";
2
1
  import React from "react";
2
+ import { SKIP } from "../../query/SKIP_TOKEN";
3
3
  export function useResourceRef(res, ...argss) {
4
4
  const args = (argss[0] === SKIP ? SKIP : argss[0]);
5
5
  return React.useMemo(() => {
@@ -1,5 +1,5 @@
1
1
  import { ReadableSignalLike } from "../../signals";
2
- import { FallbackOnNever } from "../../query/types/shared.types";
2
+ import { FallbackOnNever } from "./shared.types";
3
3
  import { ResourceDefinition, ResourceInstance } from "./Resource.types";
4
4
  /**
5
5
  * Функция создания операции
@@ -1,6 +1,6 @@
1
- import { ReadableSignalLike } from "../../signals";
2
- import { FallbackOnNever } from "../../query/types/shared.types";
3
1
  import { Patch as ImmerPatch } from "immer";
2
+ import { ReadableSignalLike } from "../../signals";
3
+ import { FallbackOnNever } from "./shared.types";
4
4
  /**
5
5
  * Функция создания ресурса
6
6
  */
@@ -0,0 +1,3 @@
1
+ export * from './Operation.types';
2
+ export * from './Resource.types';
3
+ export * from './shared.types';
@@ -0,0 +1,3 @@
1
+ export * from './Operation.types';
2
+ export * from './Resource.types';
3
+ export * from './shared.types';
@@ -1,7 +1,8 @@
1
1
  import { Observable, Subscriber, TeardownLogic } from "rxjs";
2
- import { SyncObservable } from "./SyncObservable";
3
2
  import type { ReadableSignalLike } from "./types";
3
+ import { SyncObservable } from "./SyncObservable";
4
4
  export declare class ReadonlySignal<T> extends SyncObservable<T> implements ReadableSignalLike<T> {
5
+ protected rang: number;
5
6
  private readonly _devtools;
6
7
  private static _logIdIndex;
7
8
  constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic);
@@ -1,12 +1,28 @@
1
- import { SharedOptions } from "../../query/core/SharedOptions";
1
+ import { Subscriber } from "rxjs";
2
+ import { SharedOptions } from "../../common/options/SharedOptions";
2
3
  import { SyncObservable } from "./SyncObservable";
3
4
  import { Tracker } from "./Tracker";
4
5
  export class ReadonlySignal extends SyncObservable {
6
+ rang = 0;
5
7
  _devtools;
6
8
  static _logIdIndex = 0;
7
9
  constructor(subscribe) {
8
- super(subscribe);
9
10
  const stateDevtools = SharedOptions.DEVTOOLS?.state;
11
+ const originalSubscribe = subscribe;
12
+ if (stateDevtools && originalSubscribe) {
13
+ subscribe = (subscriber) => {
14
+ const wrappedSubscriber = new Subscriber({
15
+ next: (value) => {
16
+ this._devtools?.(value);
17
+ subscriber.next(value);
18
+ },
19
+ error: (err) => subscriber.error(err),
20
+ complete: () => subscriber.complete()
21
+ });
22
+ return originalSubscribe.call(this, wrappedSubscriber);
23
+ };
24
+ }
25
+ super(subscribe);
10
26
  if (stateDevtools) {
11
27
  const id = ReadonlySignal._logIdIndex++;
12
28
  const key = `ReadonlySignal:i=${id}`;
@@ -15,7 +31,7 @@ export class ReadonlySignal extends SyncObservable {
15
31
  }
16
32
  }
17
33
  get value() {
18
- Tracker.next_legacy(this);
34
+ Tracker.next(this.rang, this);
19
35
  return super.value;
20
36
  }
21
37
  peek() {
@@ -1,10 +1,10 @@
1
1
  import { BehaviorSubject, Observable } from "rxjs";
2
- import { type ReadableSignalLike, UnaryFunction } from "./types";
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 ReadableSignalLike<T> {
7
+ export declare class Signal<T> extends BehaviorSubject<T> implements SignalLike<T> {
8
8
  private readonly _devtools;
9
9
  protected _rang: number;
10
10
  constructor(initialValue: T, options?: SignalOptions);
@@ -1,5 +1,5 @@
1
- import { SharedOptions } from "../../query/core/SharedOptions";
2
1
  import { BehaviorSubject } from "rxjs";
2
+ import { SharedOptions } from "../../common/options/SharedOptions";
3
3
  import { Batcher } from "./Batcher";
4
4
  import { Indexer } from "./Indexer";
5
5
  import { Tracker } from "./Tracker";
@@ -4,10 +4,6 @@ type TrackedValue = {
4
4
  obsv$: Observable<unknown>;
5
5
  };
6
6
  export declare const Tracker: {
7
- /** @deprecated */
8
- tracked_legacy$: Subject<Observable<unknown>>;
9
- /** @deprecated */
10
- next_legacy(value: Observable<unknown>): void;
11
7
  tracked$: Subject<TrackedValue>;
12
8
  next(rang: number, observable: Observable<unknown>): void;
13
9
  };
@@ -1,11 +1,5 @@
1
1
  import { Subject } from "rxjs";
2
2
  export const Tracker = {
3
- /** @deprecated */
4
- tracked_legacy$: new Subject(),
5
- /** @deprecated */
6
- next_legacy(value) {
7
- Tracker.tracked_legacy$.next(value);
8
- },
9
3
  tracked$: new Subject(),
10
4
  next(rang, observable) {
11
5
  Tracker.tracked$.next({ rang, obsv$: observable, });
@@ -7,6 +7,15 @@ export interface ReadableSignalLike<T = unknown> extends Observable<T> {
7
7
  */
8
8
  get(): T;
9
9
  }
10
+ export interface SignalLike<T = unknown> extends ReadableSignalLike<T> {
11
+ set value(value: T);
12
+ next(value: T): void;
13
+ asReadonly(): ReadableSignalLike<T>;
14
+ /**
15
+ * @deprecated use `value` instead.
16
+ */
17
+ set(value: T): void;
18
+ }
10
19
  export interface UnaryFunction<T, R> {
11
20
  (source: T): R;
12
21
  }
@@ -1,3 +1,4 @@
1
1
  export * from './base';
2
2
  export * from './extends';
3
3
  export * from './operators';
4
+ export * from './react';
@@ -1,3 +1,4 @@
1
1
  export * from './base';
2
2
  export * from './extends';
3
3
  export * from './operators';
4
+ export * from './react';
@@ -0,0 +1 @@
1
+ export * from './useSignal';
@@ -0,0 +1 @@
1
+ export * from './useSignal';
@@ -1,2 +1,2 @@
1
- import { ReadableSignalLike } from "../signals";
1
+ import { ReadableSignalLike } from "../../signals";
2
2
  export declare function useSignal<T>(signal$: ReadableSignalLike<T>): T;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { useEventHandler } from "../react-hooks";
2
+ import { useEventHandler } from "../../common/react";
3
3
  export function useSignal(signal$) {
4
4
  const subscribe = React.useCallback((update) => {
5
5
  const subscription = signal$.subscribe(update);
@@ -17,7 +17,7 @@ const age = new Signal(25);
17
17
  // Подписка на изменения
18
18
  const subscription = name.subscribe(newName => {
19
19
  console.log(`Name changed to: ${newName}`);
20
- });
20
+ }); // Выведет: "Name changed to: John" при инициализации
21
21
 
22
22
  name.value = 'Jane'; // Выведет: "Name changed to: Jane"
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fozy-labs/rx-toolkit",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- import { DevtoolsLike } from "../query/types/devtools";
2
- export declare function reduxDevtools(): DevtoolsLike;
File without changes
@@ -1 +0,0 @@
1
- "use strict";