@ersbeth/picoflow 0.0.1 → 0.1.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/api/doc/index.md +1 -1
- package/api/doc/picoflow.constant.md +55 -0
- package/api/doc/picoflow.derivation.md +1 -1
- package/api/doc/picoflow.effect.md +1 -1
- package/api/doc/picoflow.flowconstant._constructor_.md +49 -0
- package/api/doc/picoflow.flowconstant.get.md +25 -0
- package/api/doc/picoflow.flowconstant.md +88 -0
- package/api/doc/picoflow.flowderivation._constructor_.md +2 -2
- package/api/doc/picoflow.flowderivation.get.md +2 -2
- package/api/doc/picoflow.flowderivation.md +2 -2
- package/api/doc/picoflow.floweffect._constructor_.md +7 -2
- package/api/doc/picoflow.floweffect.dispose.md +3 -3
- package/api/doc/picoflow.floweffect.disposed.md +1 -1
- package/api/doc/picoflow.floweffect.md +4 -4
- package/api/doc/picoflow.flowgetter.md +2 -2
- package/api/doc/picoflow.flowmap._lastdeleted.md +1 -1
- package/api/doc/picoflow.flowmap._lastset.md +1 -1
- package/api/doc/picoflow.flowmap.delete.md +6 -2
- package/api/doc/picoflow.flowmap.md +5 -7
- package/api/doc/picoflow.flowmap.setat.md +6 -2
- package/api/doc/picoflow.flowobservable.get.md +3 -3
- package/api/doc/picoflow.flowobservable.md +18 -4
- package/api/doc/picoflow.flowobservable.subscribe.md +55 -0
- package/api/doc/picoflow.flowresource._constructor_.md +2 -18
- package/api/doc/picoflow.flowresource.fetch.md +1 -1
- package/api/doc/picoflow.flowresource.get.md +4 -4
- package/api/doc/picoflow.flowresource.md +4 -4
- package/api/doc/picoflow.flowresourceasync._constructor_.md +49 -0
- package/api/doc/picoflow.flowresourceasync.fetch.md +27 -0
- package/api/doc/picoflow.flowresourceasync.get.md +23 -0
- package/api/doc/picoflow.flowresourceasync.md +100 -0
- package/api/doc/picoflow.flowsignal.dispose.md +3 -7
- package/api/doc/picoflow.flowsignal.disposed.md +2 -2
- package/api/doc/picoflow.flowsignal.md +5 -5
- package/api/doc/picoflow.flowsignal.trigger.md +3 -7
- package/api/doc/picoflow.flowstate.md +4 -52
- package/api/doc/picoflow.flowstate.set.md +5 -5
- package/api/doc/picoflow.flowstream._constructor_.md +3 -19
- package/api/doc/picoflow.flowstream.dispose.md +1 -1
- package/api/doc/picoflow.flowstream.get.md +4 -4
- package/api/doc/picoflow.flowstream.md +5 -5
- package/api/doc/picoflow.flowstreamasync._constructor_.md +54 -0
- package/api/doc/picoflow.flowstreamasync.dispose.md +21 -0
- package/api/doc/picoflow.flowstreamasync.get.md +23 -0
- package/api/doc/picoflow.flowstreamasync.md +100 -0
- package/api/doc/picoflow.flowstreamdisposer.md +13 -0
- package/api/doc/picoflow.flowstreamsetter.md +13 -0
- package/api/doc/picoflow.flowstreamupdater.md +19 -0
- package/api/doc/picoflow.flowwatcher.md +1 -1
- package/api/doc/picoflow.map.md +1 -1
- package/api/doc/picoflow.md +80 -14
- package/api/doc/picoflow.resource.md +2 -18
- package/api/doc/picoflow.resourceasync.md +55 -0
- package/api/doc/picoflow.signal.md +1 -1
- package/api/doc/picoflow.state.md +3 -3
- package/api/doc/picoflow.stream.md +2 -18
- package/api/doc/picoflow.streamasync.md +55 -0
- package/api/picoflow.public.api.md +131 -0
- package/api-extractor.json +2 -1
- package/dist/picoflow.js +326 -302
- package/dist/types/advanced/index.d.ts +7 -0
- package/dist/types/advanced/index.d.ts.map +1 -0
- package/dist/types/{map.d.ts → advanced/map.d.ts} +12 -12
- package/dist/types/advanced/map.d.ts.map +1 -0
- package/dist/types/advanced/resource.d.ts +39 -0
- package/dist/types/advanced/resource.d.ts.map +1 -0
- package/dist/types/{resource.d.ts → advanced/resourceAsync.d.ts} +6 -11
- package/dist/types/advanced/resourceAsync.d.ts.map +1 -0
- package/dist/types/advanced/stream.d.ts +59 -0
- package/dist/types/advanced/stream.d.ts.map +1 -0
- package/dist/types/advanced/streamAsync.d.ts +43 -0
- package/dist/types/advanced/streamAsync.d.ts.map +1 -0
- package/dist/types/basic/constant.d.ts +32 -0
- package/dist/types/basic/constant.d.ts.map +1 -0
- package/dist/types/basic/derivation.d.ts +40 -0
- package/dist/types/basic/derivation.d.ts.map +1 -0
- package/dist/types/basic/effect.d.ts +56 -0
- package/dist/types/basic/effect.d.ts.map +1 -0
- package/dist/types/basic/index.d.ts +9 -0
- package/dist/types/basic/index.d.ts.map +1 -0
- package/dist/types/basic/observable.d.ts +34 -0
- package/dist/types/basic/observable.d.ts.map +1 -0
- package/dist/types/basic/signal.d.ts +37 -0
- package/dist/types/basic/signal.d.ts.map +1 -0
- package/dist/types/basic/state.d.ts +26 -0
- package/dist/types/basic/state.d.ts.map +1 -0
- package/dist/types/creators.d.ts +29 -13
- package/dist/types/creators.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -9
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/advanced/index.ts +10 -0
- package/src/{map.ts → advanced/map.ts} +14 -14
- package/src/advanced/resource.ts +56 -0
- package/src/{resource.ts → advanced/resourceAsync.ts} +9 -16
- package/src/advanced/stream.ts +87 -0
- package/src/advanced/streamAsync.ts +82 -0
- package/src/basic/constant.ts +64 -0
- package/src/basic/derivation.ts +86 -0
- package/src/basic/effect.ts +96 -0
- package/src/basic/index.ts +8 -0
- package/src/basic/observable.ts +51 -0
- package/src/basic/signal.ts +105 -0
- package/src/basic/state.ts +39 -0
- package/src/creators.ts +54 -15
- package/src/index.ts +21 -11
- package/test/constant.test.ts +46 -0
- package/test/derivation.test.ts +30 -6
- package/test/effect.test.ts +29 -0
- package/test/map.test.ts +38 -0
- package/test/resource.test.ts +18 -16
- package/test/resourceAsync.test.ts +108 -0
- package/test/signal.test.ts +18 -1
- package/test/state.test.ts +107 -2
- package/test/stream.test.ts +38 -13
- package/test/streamAsync.test.ts +194 -0
- package/tsconfig.json +3 -1
- package/api/doc/picoflow.flowdisposer.md +0 -13
- package/api/doc/picoflow.flowsetter.md +0 -13
- package/api/doc/picoflow.flowstate._constructor_.md +0 -49
- package/api/doc/picoflow.flowstate.get.md +0 -23
- package/api/doc/picoflow.flowupdater.md +0 -19
- package/api/picoflow.api.md +0 -145
- package/dist/types/derivation.d.ts +0 -58
- package/dist/types/derivation.d.ts.map +0 -1
- package/dist/types/effect.d.ts +0 -108
- package/dist/types/effect.d.ts.map +0 -1
- package/dist/types/map.d.ts.map +0 -1
- package/dist/types/observable.d.ts +0 -40
- package/dist/types/observable.d.ts.map +0 -1
- package/dist/types/resource.d.ts.map +0 -1
- package/dist/types/signal.d.ts +0 -111
- package/dist/types/signal.d.ts.map +0 -1
- package/dist/types/state.d.ts +0 -39
- package/dist/types/state.d.ts.map +0 -1
- package/dist/types/stream.d.ts +0 -71
- package/dist/types/stream.d.ts.map +0 -1
- package/src/derivation.ts +0 -96
- package/src/effect.ts +0 -152
- package/src/observable.ts +0 -50
- package/src/signal.ts +0 -166
- package/src/state.ts +0 -52
- package/src/stream.ts +0 -99
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { FlowMap } from './map';
|
|
2
|
+
export { FlowStream } from './stream';
|
|
3
|
+
export { FlowStreamAsync } from './streamAsync';
|
|
4
|
+
export { FlowResource } from './resource';
|
|
5
|
+
export { FlowResourceAsync } from './resourceAsync';
|
|
6
|
+
export type { FlowStreamUpdater, FlowStreamDisposer, FlowStreamSetter, } from './stream';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/advanced/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EACR,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACnB,MAAM,UAAU,CAAC"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { FlowState } from '
|
|
1
|
+
import { FlowState } from '../basic/';
|
|
2
2
|
/**
|
|
3
|
-
* Represents a reactive map of states
|
|
3
|
+
* Represents a reactive map of states extending {@link FlowState} for a Map of key/value pairs.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* FlowMap wraps a native Map and provides reactive signals for fine-grained tracking
|
|
7
7
|
* of updates to the map. In addition to the reactive capabilities inherited from FlowState,
|
|
8
|
-
* it exposes two
|
|
8
|
+
* it exposes two reactive signals:
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* • $lastSet: Holds the most recent key-value pair that was set.
|
|
11
|
+
* • $lastDeleted: Holds the most recent key-value pair that was deleted.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Use {@link FlowMap.setAt} to set a key-value pair and {@link FlowMap.delete} to remove a key.
|
|
13
|
+
* Use {@link FlowMap.setAt} to add or update a key-value pair and {@link FlowMap.delete} to remove a key.
|
|
15
14
|
*
|
|
16
15
|
* @typeparam K - The type of the map keys.
|
|
17
16
|
* @typeparam V - The type of the map values.
|
|
@@ -50,10 +49,11 @@ export declare class FlowMap<K, V> extends FlowState<Map<K, V>> {
|
|
|
50
49
|
*
|
|
51
50
|
* @param key - The key at which to set the value.
|
|
52
51
|
* @param value - The value to set.
|
|
52
|
+
* @throws If the FlowMap instance is disposed.
|
|
53
53
|
*
|
|
54
54
|
* @remarks
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* Updates the internal map, emits the key-value pair via {@link FlowMap.$lastSet},
|
|
56
|
+
* and notifies all subscribers of the change.
|
|
57
57
|
*
|
|
58
58
|
* @public
|
|
59
59
|
*/
|
|
@@ -62,11 +62,11 @@ export declare class FlowMap<K, V> extends FlowState<Map<K, V>> {
|
|
|
62
62
|
* Deletes the value at the specified key from the underlying map.
|
|
63
63
|
*
|
|
64
64
|
* @param key - The key to delete.
|
|
65
|
+
* @throws If the FlowMap instance is disposed.
|
|
65
66
|
*
|
|
66
67
|
* @remarks
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* of the change.
|
|
68
|
+
* Removes the key from the internal map, emits the deleted key and its value via {@link FlowMap.$lastDeleted},
|
|
69
|
+
* and notifies all subscribers of the change.
|
|
70
70
|
*
|
|
71
71
|
* @public
|
|
72
72
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/advanced/map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAO,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD;;;;;;;;OAQG;IACI,QAAQ,EAAE,SAAS,CAAC;QAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC,CAAqB;IAEvE;;;;;;;;OAQG;IACI,YAAY,EAAE,SAAS,CAAC;QAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC,CAAqB;IAE3E;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAOpC;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI;CAO9B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FlowObservable } from '../basic';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a reactive resource that asynchronously fetches its value.
|
|
4
|
+
*
|
|
5
|
+
* @remarks A FlowResource extends FlowObservable and encapsulates an asynchronous fetch function.
|
|
6
|
+
* It is used to retrieve and update its value asynchronously. When the fetch is executed,
|
|
7
|
+
* if the new value differs from the current value, the resource is updated and its subscribers
|
|
8
|
+
* are notified.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class FlowResource<T> extends FlowObservable<T | undefined> {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new FlowResource.
|
|
15
|
+
* @param fetch - An asynchronous function that retrieves the resource's value.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
constructor(fetch: () => Promise<T>);
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the current resource value.
|
|
22
|
+
* @returns The current value, or undefined if the resource has not been fetched yet.
|
|
23
|
+
* @throws Error if the resource is disposed.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
get(): T | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Asynchronously fetches a new value for the resource.
|
|
29
|
+
* @remarks
|
|
30
|
+
* Executes the internal fetch function. If the fetched value differs from the current one,
|
|
31
|
+
* updates the resource's value and notifies subscribers.
|
|
32
|
+
* @returns A Promise that resolves when the fetch operation is complete.
|
|
33
|
+
* @throws Error if the resource is disposed.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
fetch(): Promise<void>;
|
|
37
|
+
private _fetch;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/advanced/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;GASG;AACH,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9D;;;;;OAKG;gBACS,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC;IAKnC;;;;;OAKG;IACI,GAAG,IAAI,CAAC,GAAG,SAAS;IAK3B;;;;;;;;OAQG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAUnC,OAAO,CAAC,MAAM,CAAmB;CACpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlowObservable } from '
|
|
1
|
+
import { FlowObservable } from '../basic/';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a reactive resource that asynchronously fetches its value.
|
|
4
4
|
*
|
|
@@ -12,21 +12,20 @@ import { FlowObservable } from './observable';
|
|
|
12
12
|
*
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class FlowResourceAsync<T> extends FlowObservable<Promise<T>> {
|
|
16
16
|
/**
|
|
17
17
|
* Creates a new FlowResource.
|
|
18
18
|
* @param fetch - An asynchronous function that retrieves the resource's value.
|
|
19
|
-
* @param initial - The initial value of the resource.
|
|
20
19
|
* @public
|
|
21
20
|
*/
|
|
22
|
-
constructor(fetch: () => Promise<T
|
|
21
|
+
constructor(fetch: () => Promise<T>);
|
|
23
22
|
/**
|
|
24
23
|
* Retrieves the current resource value.
|
|
25
|
-
* @returns The current value.
|
|
24
|
+
* @returns The current value, or undefined if the resource has not been fetched yet.
|
|
26
25
|
* @throws Error if the resource is disposed.
|
|
27
26
|
* @public
|
|
28
27
|
*/
|
|
29
|
-
get(): T
|
|
28
|
+
get(): Promise<T>;
|
|
30
29
|
/**
|
|
31
30
|
* Asynchronously fetches a new value for the resource.
|
|
32
31
|
* @remarks
|
|
@@ -37,10 +36,6 @@ export declare class FlowResource<T> extends FlowObservable<T> {
|
|
|
37
36
|
* @public
|
|
38
37
|
*/
|
|
39
38
|
fetch(): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* @internal
|
|
42
|
-
* The asynchronous function used to fetch the resource value.
|
|
43
|
-
*/
|
|
44
39
|
private _fetch;
|
|
45
40
|
}
|
|
46
|
-
//# sourceMappingURL=
|
|
41
|
+
//# sourceMappingURL=resourceAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceAsync.d.ts","sourceRoot":"","sources":["../../../src/advanced/resourceAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAiB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAChE;;;;OAIG;gBACS,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC;IAKnC;;;;;OAKG;IACI,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC;IAMxB;;;;;;;;OAQG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQnC,OAAO,CAAC,MAAM,CAAmB;CACpC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FlowObservable } from '../basic/';
|
|
2
|
+
/**
|
|
3
|
+
* A function type that sets a new value for the reactive stream.
|
|
4
|
+
* @typeparam T - The type of the value.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export type FlowStreamSetter<T> = (value: T) => void;
|
|
8
|
+
/**
|
|
9
|
+
* A function type that disposes of a resource.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type FlowStreamDisposer = () => void;
|
|
13
|
+
/**
|
|
14
|
+
* A function type that updates a stream and returns a disposer for cleanup.
|
|
15
|
+
* @remarks
|
|
16
|
+
* The updater receives a setter function to update the stream's value.
|
|
17
|
+
* It should return a disposer function to release any resources or subscriptions.
|
|
18
|
+
* @typeparam T - The type of the stream value.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export type FlowStreamUpdater<T> = (set: FlowStreamSetter<T>) => FlowStreamDisposer;
|
|
22
|
+
/**
|
|
23
|
+
* Represents a reactive stream that updates its value based on an updater function.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* FlowStream extends FlowObservable to encapsulate an update mechanism provided by an external updater function.
|
|
27
|
+
* The updater is invoked during construction with a setter, and it returns a disposer to be called upon disposal.
|
|
28
|
+
* Note: The stream's current value may be undefined until explicitly set.
|
|
29
|
+
*
|
|
30
|
+
* @typeparam T - The type of the stream's value.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare class FlowStream<T> extends FlowObservable<T | undefined> {
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new FlowStream.
|
|
36
|
+
* @param updater - A function that receives a setter to update the stream's value.
|
|
37
|
+
* It should return a disposer function that will be called upon disposal.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
constructor(updater: FlowStreamUpdater<T>);
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves the current value of the stream.
|
|
43
|
+
* @returns The current value, or undefined if no value has been set yet.
|
|
44
|
+
* @throws Error if the stream is disposed.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
get(): T | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Disposes the stream, releasing all resources.
|
|
50
|
+
* @remarks
|
|
51
|
+
* In addition to disposing the underlying observable, this method calls the disposer
|
|
52
|
+
* returned by the updater.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
dispose(): void;
|
|
56
|
+
private _disposer;
|
|
57
|
+
private _set;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/advanced/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAC/B,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,KACvB,kBAAkB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,GAAG,SAAS,CAAC;IAC5D;;;;;OAKG;gBACS,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAOzC;;;;;OAKG;IACI,GAAG,IAAI,CAAC,GAAG,SAAS;IAK3B;;;;;;OAMG;IACa,OAAO,IAAI,IAAI;IAO/B,OAAO,CAAC,SAAS,CAAqB;IAEtC,OAAO,CAAC,IAAI;CAOf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FlowObservable } from '../basic';
|
|
2
|
+
import { FlowStreamUpdater } from './stream';
|
|
3
|
+
/**
|
|
4
|
+
* Represents an asynchronous reactive stream that updates its value based on an updater function.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A FlowStreamAsync extends FlowObservable and encapsulates a mechanism for asynchronously updating its value.
|
|
8
|
+
* The updater is invoked during construction with a setter, and its returned disposer is called upon disposal.
|
|
9
|
+
* Note: The stream's current value may be undefined until it is set.
|
|
10
|
+
*
|
|
11
|
+
* @typeparam T - The type of the stream's value.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class FlowStreamAsync<T> extends FlowObservable<Promise<T>> {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new asynchronous FlowStream.
|
|
17
|
+
* @param updater - A function that receives a setter to update the stream's value.
|
|
18
|
+
* It should return a disposer function that will be called upon disposal.
|
|
19
|
+
* @remarks The updater function can invoke the setter asynchronously to update the stream.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
constructor(updater: FlowStreamUpdater<T>);
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the current value of the stream as a Promise.
|
|
25
|
+
* @returns A Promise that resolves to the current value.
|
|
26
|
+
* @throws Error if the stream is disposed.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
get(): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Disposes the stream, releasing all resources.
|
|
32
|
+
* @remarks In addition to disposing the underlying observable, this method calls the disposer
|
|
33
|
+
* returned by the updater.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
dispose(): void;
|
|
37
|
+
private _initialized;
|
|
38
|
+
private _awaitedValue?;
|
|
39
|
+
private _resolve;
|
|
40
|
+
private _disposer;
|
|
41
|
+
private _set;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=streamAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamAsync.d.ts","sourceRoot":"","sources":["../../../src/advanced/streamAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAsB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,qBAAa,eAAe,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9D;;;;;;OAMG;gBACS,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAWzC;;;;;OAKG;IACI,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC;IAKxB;;;;;OAKG;IACa,OAAO,IAAI,IAAI;IAO/B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAC,CAAI;IAE1B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAAqB;IAEtC,OAAO,CAAC,IAAI;CAkBf"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FlowObservable } from './observable';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a reactive and immutable constant value computed lazily upon first access.
|
|
4
|
+
*
|
|
5
|
+
* @remarks This class extends FlowObservable and supports initializing the constant using either a direct value
|
|
6
|
+
* or a lazy initializer function. Once computed, the value is cached for all subsequent accesses.
|
|
7
|
+
*
|
|
8
|
+
* @typeparam T - The type of the constant value.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class FlowConstant<T> extends FlowObservable<T> {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new FlowConstant instance.
|
|
15
|
+
*
|
|
16
|
+
* @param value - Either a direct value of type T or a function returning a value of type T for lazy initialization.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
constructor(value: T | (() => T));
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the constant value, computing it lazily if needed.
|
|
22
|
+
*
|
|
23
|
+
* Accessing this method will initialize the value if it has not been computed already.
|
|
24
|
+
* Throws an error if the instance has been disposed or if lazy initialization fails.
|
|
25
|
+
*
|
|
26
|
+
* @returns The cached constant value.
|
|
27
|
+
* @throws Error if the constant is disposed or cannot be initialized.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
get(): T;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/basic/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;GASG;AACH,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAClD;;;;;OAKG;gBACS,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAKhC;;;;;;;;;OASG;IACH,GAAG,IAAI,CAAC;CA6BX"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FlowGetter, FlowObservable } from './observable';
|
|
2
|
+
import { FlowWatcher } from './signal';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a reactive derivation whose value is computed based on other reactive signals.
|
|
5
|
+
* @remarks
|
|
6
|
+
* It tracks dependencies automatically and recomputes its value when any dependency changes.
|
|
7
|
+
* Use FlowDerivation to create derived values in a reactive manner. It lazily initializes the computed value,
|
|
8
|
+
* ensuring that computations only occur when necessary.
|
|
9
|
+
* @typeparam T - The type of the computed value.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class FlowDerivation<T> extends FlowObservable<T> {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new FlowDerivation.
|
|
15
|
+
* @param compute - A function that computes the derived value. It is provided with two parameters:
|
|
16
|
+
* a getter and a watcher that respect dependency tracking.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
constructor(compute: (get: FlowGetter, watch: FlowWatcher) => T);
|
|
20
|
+
/**
|
|
21
|
+
* Gets the current derived value.
|
|
22
|
+
* @returns The current computed value.
|
|
23
|
+
* @remarks
|
|
24
|
+
* This method lazily initializes and updates the derivation if it is marked as dirty. It throws an error
|
|
25
|
+
* if the derivation has been disposed.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
get(): T;
|
|
29
|
+
private _initialized;
|
|
30
|
+
private _dirty;
|
|
31
|
+
private _trackedGet;
|
|
32
|
+
private _trackedWatch;
|
|
33
|
+
private _untrackedGet;
|
|
34
|
+
private _untrackedWatch;
|
|
35
|
+
private _trackedCompute;
|
|
36
|
+
private _untrackedCompute;
|
|
37
|
+
private _initEager;
|
|
38
|
+
private _initLazy;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=derivation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivation.d.ts","sourceRoot":"","sources":["../../../src/basic/derivation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;GAQG;AACH,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACpD;;;;;OAKG;gBACS,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,CAAC;IAK/D;;;;;;;OAOG;IACI,GAAG,IAAI,CAAC;IASf,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,WAAW,CAAyD;IAC5E,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,aAAa,CAAgD;IACrE,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,iBAAiB,CAAW;IAEpC,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,SAAS;CAyBpB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { FlowGetter } from './observable';
|
|
2
|
+
import { FlowWatcher } from './signal';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a reactive effect that executes side-effect functions based
|
|
5
|
+
* on its tracked dependencies.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The FlowEffect executes an apply function that performs side effects,
|
|
9
|
+
* running initially in a tracked mode to register dependencies and then in
|
|
10
|
+
* an untracked mode to re-execute the effect on updates.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class FlowEffect {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new FlowEffect.
|
|
17
|
+
*
|
|
18
|
+
* @param apply - A side-effect function that receives a getter and a watcher to
|
|
19
|
+
* access and register dependencies on reactive observables and signals.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* The provided function is executed immediately in a tracked mode to collect dependencies.
|
|
23
|
+
* On subsequent executions, it runs in an untracked mode.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
constructor(apply: (get: FlowGetter, watch: FlowWatcher) => void);
|
|
28
|
+
/**
|
|
29
|
+
* Disposes the effect, unregistering all its tracked dependencies.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Once disposed, the effect must no longer be used. Trying to dispose an effect
|
|
33
|
+
* that is already disposed will throw an error.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
dispose(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Indicates whether this effect has been disposed.
|
|
40
|
+
*
|
|
41
|
+
* @returns A boolean value that is true if the effect is disposed, false otherwise.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
get disposed(): boolean;
|
|
46
|
+
private _disposed;
|
|
47
|
+
private _initialized;
|
|
48
|
+
private _dependencies;
|
|
49
|
+
private _trackedGet;
|
|
50
|
+
private _trackedWatch;
|
|
51
|
+
private _untrackedGet;
|
|
52
|
+
private _untrackedWatch;
|
|
53
|
+
private _trackedExec;
|
|
54
|
+
private _untrackedExec;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../../src/basic/effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACnB;;;;;;;;;;;OAWG;gBACS,KAAK,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI;IAOhE;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI;IAQtB;;;;;;OAMG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAID,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAyB;IAE9C,OAAO,CAAC,WAAW,CAAyD;IAC5E,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,aAAa,CAAgD;IACrE,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,cAAc,CAAa;CAsBtC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { FlowSignal } from './signal';
|
|
2
|
+
export { FlowState } from './state';
|
|
3
|
+
export { FlowObservable } from './observable';
|
|
4
|
+
export { FlowDerivation } from './derivation';
|
|
5
|
+
export { FlowEffect } from './effect';
|
|
6
|
+
export { FlowConstant } from './constant';
|
|
7
|
+
export type { FlowGetter } from './observable';
|
|
8
|
+
export type { FlowWatcher } from './signal';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/basic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FlowSignal } from './signal';
|
|
2
|
+
/**
|
|
3
|
+
* A function that retrieves the current value from a FlowObservable.
|
|
4
|
+
* @typeparam T - The type of the value held by the observable.
|
|
5
|
+
* @param observable - The FlowObservable instance to retrieve the value from.
|
|
6
|
+
* @returns The current value of the observable.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export type FlowGetter = <T>(observable: FlowObservable<T>) => T;
|
|
10
|
+
/**
|
|
11
|
+
* Represents a reactive observable that holds and tracks a value.
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* @remarks Subclasses must implement the {@link FlowObservable.get} method to return the current value.
|
|
15
|
+
* @typeparam T - The type of the value held by the observable.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class FlowObservable<T> extends FlowSignal {
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the current value stored in the observable.
|
|
21
|
+
* Subclasses must override this method to provide the current value.
|
|
22
|
+
* @returns The current value of type T.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
abstract get(): T;
|
|
26
|
+
/**
|
|
27
|
+
* Subscribes a listener function to changes of the observable.
|
|
28
|
+
* The listener is executed immediately with the current value and on subsequent updates.
|
|
29
|
+
* @param listener - A callback function that receives the new value.
|
|
30
|
+
* @returns A disposer function to cancel the subscription.
|
|
31
|
+
*/
|
|
32
|
+
subscribe(listener: (value: T) => void): () => void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=observable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../../src/basic/observable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAEjE;;;;;;;GAOG;AACH,8BAAsB,cAAc,CAAC,CAAC,CAAE,SAAQ,UAAU;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,IAAI,CAAC;IAWjB;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;CAMtD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A function for watching a FlowSignal.
|
|
3
|
+
* @param signal - The FlowSignal that is being observed.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type FlowWatcher = (signal: FlowSignal) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Represents a reactive signal.
|
|
9
|
+
*
|
|
10
|
+
* @remarks Use FlowSignal to create reactive streams that notify listeners and execute associated effects.
|
|
11
|
+
* Signals can be triggered and disposed. Once disposed, interactions with the signal will throw errors.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class FlowSignal {
|
|
15
|
+
/**
|
|
16
|
+
* Triggers the FlowSignal.
|
|
17
|
+
* Notifies all registered listeners and schedules execution of associated effects.
|
|
18
|
+
* @throws If the FlowSignal has already been disposed.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
trigger(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Disposes the FlowSignal.
|
|
24
|
+
* Cleans up all registered effects, listeners, and dependencies.
|
|
25
|
+
* Once disposed, further usage of the signal will throw an error.
|
|
26
|
+
* @throws If the FlowSignal is already disposed.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
dispose(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Indicates whether the FlowSignal has been disposed.
|
|
32
|
+
* @remarks Once disposed, the signal should not be used.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
get disposed(): boolean;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../../src/basic/signal.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAEvD;;;;;;GAMG;AACH,qBAAa,UAAU;IACnB;;;;;OAKG;IACI,OAAO,IAAI,IAAI;IAKtB;;;;;;OAMG;IACI,OAAO,IAAI,IAAI;IAUtB;;;;OAIG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;CAoDJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FlowConstant } from './constant';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a reactive state that holds a mutable value.
|
|
4
|
+
*
|
|
5
|
+
* @typeparam T - The type of the state value.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* FlowState extends FlowConstant, which provides the {@link FlowConstant.get} method to read
|
|
9
|
+
* the current state. Use the {@link FlowState.set} method to update the state. When the state is updated,
|
|
10
|
+
* subscribers are notified automatically. This class notifies subscribers only when the value changes.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class FlowState<T> extends FlowConstant<T> {
|
|
15
|
+
/**
|
|
16
|
+
* Updates the state with a new value.
|
|
17
|
+
* @param value - A new value or a callback function that computes a new value based on the current state.
|
|
18
|
+
* @remarks
|
|
19
|
+
* If the computed new value is strictly equal to the current state value, no change is made and subscribers
|
|
20
|
+
* will not be notified. Otherwise, the state is updated and all subscribers are informed of the change.
|
|
21
|
+
* @throws Error if the state has been disposed.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
set(value: T | ((current: T) => T)): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/basic/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,qBAAa,SAAS,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;IAC7C;;;;;;;;OAQG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI;CAc5C"}
|
package/dist/types/creators.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FlowEffect } from './
|
|
3
|
-
import { FlowGetter } from './observable';
|
|
4
|
-
import { FlowResource } from './resource';
|
|
5
|
-
import { FlowSignal, FlowWatcher } from './signal';
|
|
6
|
-
import { FlowState } from './state';
|
|
7
|
-
import { FlowMap } from './map';
|
|
8
|
-
import { FlowStream } from './stream';
|
|
1
|
+
import { FlowMap, FlowResource, FlowResourceAsync, FlowStream, FlowStreamAsync } from './advanced/';
|
|
2
|
+
import { FlowConstant, FlowDerivation, FlowEffect, FlowSignal, FlowState, FlowGetter, FlowWatcher } from './basic/';
|
|
9
3
|
/**
|
|
10
4
|
* Creates a new reactive signal.
|
|
11
5
|
* @returns A new instance of {@link FlowSignal}.
|
|
12
6
|
* @public
|
|
13
7
|
*/
|
|
14
8
|
export declare function signal(): FlowSignal;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new reactive constant.
|
|
11
|
+
* @param value - The value or a function that returns the value.
|
|
12
|
+
* @returns A new instance of {@link FlowConstant}.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare function constant<T>(value: T | (() => T)): FlowConstant<T>;
|
|
15
16
|
/**
|
|
16
17
|
* Creates a new reactive state holding a value.
|
|
17
18
|
* @typeparam T - The type of the state value.
|
|
@@ -19,26 +20,41 @@ export declare function signal(): FlowSignal;
|
|
|
19
20
|
* @returns A new instance of {@link FlowState}.
|
|
20
21
|
* @public
|
|
21
22
|
*/
|
|
22
|
-
export declare function state<T>(value: T): FlowState<T>;
|
|
23
|
+
export declare function state<T>(value: T | (() => T)): FlowState<T>;
|
|
23
24
|
/**
|
|
24
25
|
* Creates a new reactive resource that asynchronously fetches its value.
|
|
25
26
|
* @typeparam T - The type of the resource value.
|
|
26
27
|
* @param fn - An asynchronous function that fetches the resource value.
|
|
27
|
-
* @param initial - The initial value of the resource.
|
|
28
28
|
* @returns A new instance of {@link FlowResource}.
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
export declare function resource<T>(fn: () => Promise<T
|
|
31
|
+
export declare function resource<T>(fn: () => Promise<T>): FlowResource<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new reactive asynchronous resource that fetches its value.
|
|
34
|
+
* @typeparam T - The type of the resource value.
|
|
35
|
+
* @param fn - An asynchronous function that fetches the resource value.
|
|
36
|
+
* @returns A new instance of {@link FlowResourceAsync}.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare function resourceAsync<T>(fn: () => Promise<T>): FlowResourceAsync<T>;
|
|
32
40
|
/**
|
|
33
41
|
* Creates a new reactive stream.
|
|
34
42
|
* @typeparam T - The type of the stream value.
|
|
35
43
|
* @param updater - A function that receives a setter to update the stream's value.
|
|
36
44
|
* It should return a disposer function to clean up resources.
|
|
37
|
-
* @param initial - The initial value of the stream.
|
|
38
45
|
* @returns A new instance of {@link FlowStream}.
|
|
39
46
|
* @public
|
|
40
47
|
*/
|
|
41
|
-
export declare function stream<T>(updater: (set: (value: T) => void) => () => void
|
|
48
|
+
export declare function stream<T>(updater: (set: (value: T) => void) => () => void): FlowStream<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new reactive asynchronous stream.
|
|
51
|
+
* @typeparam T - The type of the stream value.
|
|
52
|
+
* @param updater - A function that receives a setter to update the stream's value.
|
|
53
|
+
* It should return a disposer function to clean up resources.
|
|
54
|
+
* @returns A new instance of {@link FlowStreamAsync}.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export declare function streamAsync<T>(updater: (set: (value: T) => void) => () => void): FlowStreamAsync<T>;
|
|
42
58
|
/**
|
|
43
59
|
* Creates a new reactive derivation whose value is computed based on other reactive signals.
|
|
44
60
|
* @typeparam T - The type of the derived value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creators.d.ts","sourceRoot":"","sources":["../../src/creators.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"creators.d.ts","sourceRoot":"","sources":["../../src/creators.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,eAAe,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,YAAY,EACZ,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,UAAU,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAE3E;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACpB,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,GACjD,UAAU,CAAC,CAAC,CAAC,CAEf;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EACzB,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,GACjD,eAAe,CAAC,CAAC,CAAC,CAEpB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EACxB,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,CAAC,GAC/C,cAAc,CAAC,CAAC,CAAC,CAEnB;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAClB,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,GAClD,UAAU,CAEZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACrD,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAIf"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,13 +6,7 @@
|
|
|
6
6
|
* effects, and reactive maps.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
export { signal, state, resource, stream, derivation, effect, map } from './creators';
|
|
10
|
-
export type { FlowDerivation } from './
|
|
11
|
-
export type {
|
|
12
|
-
export type { FlowGetter, FlowObservable } from './observable';
|
|
13
|
-
export type { FlowResource } from './resource';
|
|
14
|
-
export type { FlowSignal, FlowWatcher } from './signal';
|
|
15
|
-
export type { FlowState } from './state';
|
|
16
|
-
export type { FlowMap } from './map';
|
|
17
|
-
export type { FlowStream, FlowDisposer, FlowSetter, FlowUpdater } from './stream';
|
|
9
|
+
export { signal, state, constant, resource, stream, derivation, effect, map, streamAsync, resourceAsync, } from './creators';
|
|
10
|
+
export type { FlowDerivation, FlowEffect, FlowGetter, FlowObservable, FlowSignal, FlowWatcher, FlowState, FlowConstant, } from './basic/';
|
|
11
|
+
export type { FlowResource, FlowMap, FlowResourceAsync, FlowStreamAsync, FlowStream, FlowStreamDisposer, FlowStreamSetter, FlowStreamUpdater, } from './advanced/';
|
|
18
12
|
//# sourceMappingURL=index.d.ts.map
|