@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.
- package/README.md +4 -5
- package/dist/{devtools → common/devtools}/combineDevtools.d.ts +1 -1
- package/dist/{devtools → common/devtools}/index.d.ts +1 -0
- package/dist/{devtools → common/devtools}/index.js +1 -0
- package/dist/common/devtools/reduxDevtools.d.ts +2 -0
- package/dist/{devtools → common/devtools}/reduxDevtools.js +1 -1
- package/dist/{query/api → common/options}/DefaultOptions.d.ts +1 -1
- package/dist/{query/api → common/options}/DefaultOptions.js +1 -1
- package/dist/{query/core → common/options}/SharedOptions.d.ts +1 -1
- package/dist/common/options/index.d.ts +1 -0
- package/dist/common/options/index.js +1 -0
- package/dist/{react-hooks → common/react}/index.d.ts +2 -3
- package/dist/{react-hooks → common/react}/index.js +2 -3
- package/dist/{react-hooks → common/react}/useObservable.js +2 -2
- package/dist/{react-hooks → common/react}/useSyncObservable.js +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/query/api/createOperation.d.ts +1 -5
- package/dist/query/api/createOperation.js +0 -4
- package/dist/query/api/createResource.d.ts +1 -1
- package/dist/query/core/Opertation/Operation.d.ts +2 -3
- package/dist/query/core/Opertation/Operation.js +1 -1
- package/dist/query/core/Opertation/OperationAgent.d.ts +2 -2
- package/dist/query/core/QueriesCache.js +2 -2
- package/dist/query/core/Resource/Resource.d.ts +2 -2
- package/dist/query/core/Resource/Resource.js +2 -2
- package/dist/query/core/Resource/ResourceAgent.d.ts +1 -1
- package/dist/query/core/Resource/ResourceRef.d.ts +1 -1
- package/dist/query/index.d.ts +0 -1
- package/dist/query/index.js +0 -1
- package/dist/query/lib/IndirectMap.js +1 -1
- package/dist/query/react/useOperationAgent.d.ts +1 -2
- package/dist/query/react/useOperationAgent.js +2 -1
- package/dist/query/react/useResourceAgent.d.ts +2 -3
- package/dist/query/react/useResourceAgent.js +4 -3
- package/dist/query/react/useResourceRef.d.ts +1 -2
- package/dist/query/react/useResourceRef.js +1 -1
- package/dist/query/types/Operation.types.d.ts +1 -1
- package/dist/query/types/Resource.types.d.ts +2 -2
- package/dist/query/types/index.d.ts +3 -0
- package/dist/query/types/index.js +3 -0
- package/dist/signals/base/ReadonlySignal.d.ts +2 -1
- package/dist/signals/base/ReadonlySignal.js +19 -3
- package/dist/signals/base/Signal.d.ts +2 -2
- package/dist/signals/base/Signal.js +1 -1
- package/dist/signals/base/Tracker.d.ts +0 -4
- package/dist/signals/base/Tracker.js +0 -6
- package/dist/signals/base/types.d.ts +9 -0
- package/dist/signals/index.d.ts +1 -0
- package/dist/signals/index.js +1 -0
- package/dist/signals/react/index.d.ts +1 -0
- package/dist/signals/react/index.js +1 -0
- package/dist/{react-hooks → signals/react}/useSignal.d.ts +1 -1
- package/dist/{react-hooks → signals/react}/useSignal.js +1 -1
- package/docs/signals/README.md +1 -1
- package/package.json +1 -1
- package/dist/devtools/reduxDevtools.d.ts +0 -2
- package/dist/query/api/createSubResource.d.ts +0 -0
- package/dist/query/api/createSubResource.js +0 -1
- /package/dist/{devtools → common/devtools}/combineDevtools.js +0 -0
- /package/dist/{query/types/devtools.d.ts → common/devtools/types.d.ts} +0 -0
- /package/dist/{query/types/devtools.js → common/devtools/types.js} +0 -0
- /package/dist/{query/core → common/options}/SharedOptions.js +0 -0
- /package/dist/{react-hooks → common/react}/useConstant.d.ts +0 -0
- /package/dist/{react-hooks → common/react}/useConstant.js +0 -0
- /package/dist/{react-hooks → common/react}/useEventHandler.d.ts +0 -0
- /package/dist/{react-hooks → common/react}/useEventHandler.js +0 -0
- /package/dist/{react-hooks → common/react}/useObservable.d.ts +0 -0
- /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
|
-
//
|
|
44
|
+
// Описываем логику в обычном JavaScript
|
|
45
45
|
const store = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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 "
|
|
1
|
+
import { DevtoolsLike } from "./types";
|
|
2
2
|
export declare function combineDevtools(...devtools: DevtoolsLike[]): DevtoolsLike;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DefaultOptions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DefaultOptions';
|
|
@@ -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 "
|
|
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
|
|
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
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import type { OperationCreateOptions, OperationDefinition } from "../../query/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,3 +1,3 @@
|
|
|
1
|
-
import type { ResourceCreateOptions, ResourceDefinition } from "../../query/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
|
|
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
|
|
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("
|
|
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
|
|
3
|
-
import { QueriesCache } from "
|
|
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 {
|
|
2
|
-
import {
|
|
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
|
|
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;
|
package/dist/query/index.d.ts
CHANGED
package/dist/query/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { OperationAgentInstanse, OperationDefinition, OperationQueryState } from "
|
|
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
|
|
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 "
|
|
2
|
-
import {
|
|
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
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
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
1
|
import { ReadableSignalLike } from "../../signals";
|
|
2
|
-
import { FallbackOnNever } from "
|
|
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
|
*/
|
|
@@ -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 {
|
|
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.
|
|
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 {
|
|
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
|
|
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
|
}
|
package/dist/signals/index.d.ts
CHANGED
package/dist/signals/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSignal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSignal';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ReadableSignalLike } from "
|
|
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 "
|
|
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);
|
package/docs/signals/README.md
CHANGED
|
@@ -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
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|