@ersbeth/picoflow 0.0.1
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/.vscode/settings.json +5 -0
- package/README.md +151 -0
- package/api/doc/index.md +31 -0
- package/api/doc/picoflow.derivation.md +55 -0
- package/api/doc/picoflow.effect.md +55 -0
- package/api/doc/picoflow.flowderivation._constructor_.md +49 -0
- package/api/doc/picoflow.flowderivation.get.md +23 -0
- package/api/doc/picoflow.flowderivation.md +86 -0
- package/api/doc/picoflow.flowdisposer.md +13 -0
- package/api/doc/picoflow.floweffect._constructor_.md +49 -0
- package/api/doc/picoflow.floweffect.dispose.md +21 -0
- package/api/doc/picoflow.floweffect.disposed.md +13 -0
- package/api/doc/picoflow.floweffect.md +131 -0
- package/api/doc/picoflow.flowgetter.md +15 -0
- package/api/doc/picoflow.flowmap._lastdeleted.md +21 -0
- package/api/doc/picoflow.flowmap._lastset.md +21 -0
- package/api/doc/picoflow.flowmap.delete.md +57 -0
- package/api/doc/picoflow.flowmap.md +135 -0
- package/api/doc/picoflow.flowmap.setat.md +73 -0
- package/api/doc/picoflow.flowobservable.get.md +19 -0
- package/api/doc/picoflow.flowobservable.md +54 -0
- package/api/doc/picoflow.flowresource._constructor_.md +65 -0
- package/api/doc/picoflow.flowresource.fetch.md +27 -0
- package/api/doc/picoflow.flowresource.get.md +23 -0
- package/api/doc/picoflow.flowresource.md +100 -0
- package/api/doc/picoflow.flowsetter.md +13 -0
- package/api/doc/picoflow.flowsignal.dispose.md +25 -0
- package/api/doc/picoflow.flowsignal.disposed.md +18 -0
- package/api/doc/picoflow.flowsignal.md +111 -0
- package/api/doc/picoflow.flowsignal.trigger.md +25 -0
- package/api/doc/picoflow.flowstate._constructor_.md +49 -0
- package/api/doc/picoflow.flowstate.get.md +23 -0
- package/api/doc/picoflow.flowstate.md +100 -0
- package/api/doc/picoflow.flowstate.set.md +61 -0
- package/api/doc/picoflow.flowstream._constructor_.md +65 -0
- package/api/doc/picoflow.flowstream.dispose.md +21 -0
- package/api/doc/picoflow.flowstream.get.md +23 -0
- package/api/doc/picoflow.flowstream.md +100 -0
- package/api/doc/picoflow.flowupdater.md +19 -0
- package/api/doc/picoflow.flowwatcher.md +15 -0
- package/api/doc/picoflow.map.md +59 -0
- package/api/doc/picoflow.md +287 -0
- package/api/doc/picoflow.resource.md +71 -0
- package/api/doc/picoflow.signal.md +19 -0
- package/api/doc/picoflow.state.md +55 -0
- package/api/doc/picoflow.stream.md +71 -0
- package/api/picoflow.api.md +145 -0
- package/api-extractor.json +60 -0
- package/biome.json +34 -0
- package/dist/picoflow.js +572 -0
- package/dist/types/creators.d.ts +70 -0
- package/dist/types/creators.d.ts.map +1 -0
- package/dist/types/derivation.d.ts +58 -0
- package/dist/types/derivation.d.ts.map +1 -0
- package/dist/types/effect.d.ts +108 -0
- package/dist/types/effect.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/map.d.ts +75 -0
- package/dist/types/map.d.ts.map +1 -0
- package/dist/types/observable.d.ts +40 -0
- package/dist/types/observable.d.ts.map +1 -0
- package/dist/types/resource.d.ts +46 -0
- package/dist/types/resource.d.ts.map +1 -0
- package/dist/types/signal.d.ts +111 -0
- package/dist/types/signal.d.ts.map +1 -0
- package/dist/types/state.d.ts +39 -0
- package/dist/types/state.d.ts.map +1 -0
- package/dist/types/stream.d.ts +71 -0
- package/dist/types/stream.d.ts.map +1 -0
- package/package.json +40 -0
- package/src/creators.ts +101 -0
- package/src/derivation.ts +96 -0
- package/src/effect.ts +152 -0
- package/src/index.ts +30 -0
- package/src/map.ts +83 -0
- package/src/observable.ts +50 -0
- package/src/resource.ts +64 -0
- package/src/signal.ts +166 -0
- package/src/state.ts +52 -0
- package/src/stream.ts +99 -0
- package/test/derivation.test.ts +422 -0
- package/test/map.test.ts +106 -0
- package/test/resource.test.ts +127 -0
- package/test/signal.test.ts +59 -0
- package/test/state.test.ts +89 -0
- package/test/stream.test.ts +171 -0
- package/tsconfig.json +22 -0
- package/vite.config.ts +26 -0
- package/vitest.config.ts +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Picoflow
|
|
2
|
+
|
|
3
|
+
**Picoflow** is a lightweight reactive dataflow library that provides fine-grained reactive primitives. It gives you an intuitive API for signals, state, asynchronous resources, streams, derivations, effects, and reactive maps. Instead of using traditional subscriptions, Picoflow uses effects to automatically track reactive dependencies.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Reactive Signals:** Manually trigger updates using `$signal.trigger()`.
|
|
8
|
+
- **Reactive State:** Manage state with observables that expose getter/setter APIs.
|
|
9
|
+
- **Asynchronous Resources:** Fetch and update asynchronous data reactively.
|
|
10
|
+
- **Reactive Streams:** Create streams that update over time using an updater function.
|
|
11
|
+
- **Derivations:** Compute derived values from other reactive primitives.
|
|
12
|
+
- **Automatic Caching:** Derived values are cached and are re-evaluated only when one or more of their dependencies change.
|
|
13
|
+
- **Lazy Evaluation:** Derivations are evaluated lazily—that is, the computation only runs if and when an effect actually uses the derived value.
|
|
14
|
+
- **Reactive Maps:** Manage collections reactively with granular update notifications.
|
|
15
|
+
- **Effects:** Automatically run side-effect functions when dependencies change.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install via npm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @ersbeth/picoflow
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
In Picoflow, we advise to prefix all reactive primitives and effects with `$` for improved readability. Rather than using a subscribe method, you always create an effect that "watches" a primitive. Below are some examples:
|
|
28
|
+
|
|
29
|
+
### Creating a Signal
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { signal, effect } from 'picoflow';
|
|
33
|
+
|
|
34
|
+
const $signal = signal();
|
|
35
|
+
|
|
36
|
+
const $effect = effect((get, watch) => {
|
|
37
|
+
// Automatically tracks $signal
|
|
38
|
+
watch($signal);
|
|
39
|
+
console.log('$signal has been triggered');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Trigger the signal
|
|
43
|
+
$signal.trigger();
|
|
44
|
+
|
|
45
|
+
// LOG -> $signal has been triggered
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Creating Reactive State
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { state, effect } from 'picoflow';
|
|
52
|
+
|
|
53
|
+
const $count = state(0);
|
|
54
|
+
|
|
55
|
+
const $effect = effect((get, watch) => {
|
|
56
|
+
// Automatically tracks $count
|
|
57
|
+
console.log('Count changed:', get($count));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Update the state
|
|
61
|
+
$count.set(42);
|
|
62
|
+
|
|
63
|
+
// LOG -> $Count changed: 42
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Creating an Asynchronous Resource
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { resource, effect } from 'picoflow';
|
|
70
|
+
|
|
71
|
+
async function fetchData() {
|
|
72
|
+
const response = await fetch('https://api.example.com/data');
|
|
73
|
+
return response.json();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const $data = resource(fetchData, {});
|
|
77
|
+
|
|
78
|
+
// Create an effect to watch for updates
|
|
79
|
+
const $effect = effect((get, watch) => {
|
|
80
|
+
console.log('Resource updated:', get($data));
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Later, you can trigger a new fetch
|
|
84
|
+
$data.fetch();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Creating a Reactive Stream
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { stream, effect } from 'picoflow';
|
|
91
|
+
|
|
92
|
+
const $ticker = stream(
|
|
93
|
+
(set) => {
|
|
94
|
+
const interval = setInterval(() => set(Date.now()), 1000);
|
|
95
|
+
// Return a disposer to clear the interval when the stream is disposed.
|
|
96
|
+
return () => clearInterval(interval);
|
|
97
|
+
},
|
|
98
|
+
Date.now()
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const $effect = effect((get, watch) => {
|
|
102
|
+
console.log('Current time:', get($ticker));
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Creating a Derived Value
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { state, derivation, effect } from 'picoflow';
|
|
110
|
+
|
|
111
|
+
const $a = state(10);
|
|
112
|
+
const $b = state(20);
|
|
113
|
+
|
|
114
|
+
// Create a derived value that sums $a and $b.
|
|
115
|
+
const $sum = derivation((get, watch) => {
|
|
116
|
+
return get($a) + get($b);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const $effect = effect((get, watch) => {
|
|
120
|
+
console.log('Sum:', get($sum));
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Update a dependency to see the derivation update.
|
|
124
|
+
$a.set(15);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Creating a Reactive Map
|
|
128
|
+
|
|
129
|
+
Reactive maps allow fine-grained tracking of collection updates.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { map, effect } from 'picoflow';
|
|
133
|
+
|
|
134
|
+
const $map = map({ foo: 'bar' });
|
|
135
|
+
|
|
136
|
+
const $effect = effect((get, watch) => {
|
|
137
|
+
console.log('Map updated:', get($map));
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Update the map to trigger updates
|
|
141
|
+
$map.setAt('baz', 'qux');
|
|
142
|
+
$map.delete('foo');
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## API Documentation
|
|
146
|
+
|
|
147
|
+
For detailed API documentation, please refer to the [API Reference](./api/doc/index.md).
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
This project is licensed under the [MIT License](LICENSE).
|
package/api/doc/index.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md)
|
|
4
|
+
|
|
5
|
+
## API Reference
|
|
6
|
+
|
|
7
|
+
## Packages
|
|
8
|
+
|
|
9
|
+
<table><thead><tr><th>
|
|
10
|
+
|
|
11
|
+
Package
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
</th><th>
|
|
15
|
+
|
|
16
|
+
Description
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
</th></tr></thead>
|
|
20
|
+
<tbody><tr><td>
|
|
21
|
+
|
|
22
|
+
[picoflow](./picoflow.md)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
</td><td>
|
|
26
|
+
|
|
27
|
+
PicoFlow is a lightweight reactive dataflow library that provides a set of reactive primitives such as signals, state, resources, streams, derivations, effects, and reactive maps.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
</td></tr>
|
|
31
|
+
</tbody></table>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [derivation](./picoflow.derivation.md)
|
|
4
|
+
|
|
5
|
+
## derivation() function
|
|
6
|
+
|
|
7
|
+
Creates a new reactive derivation whose value is computed based on other reactive signals.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare function derivation<T>(fn: (get: FlowGetter, watch: FlowWatcher) => T): FlowDerivation<T>;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
<table><thead><tr><th>
|
|
18
|
+
|
|
19
|
+
Parameter
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
</th><th>
|
|
23
|
+
|
|
24
|
+
Type
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
</th><th>
|
|
28
|
+
|
|
29
|
+
Description
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</th></tr></thead>
|
|
33
|
+
<tbody><tr><td>
|
|
34
|
+
|
|
35
|
+
fn
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</td><td>
|
|
39
|
+
|
|
40
|
+
(get: [FlowGetter](./picoflow.flowgetter.md)<!-- -->, watch: [FlowWatcher](./picoflow.flowwatcher.md)<!-- -->) => T
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
A function that computes the derived value. It receives a getter and a watcher function to access and register dependencies.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
</td></tr>
|
|
49
|
+
</tbody></table>
|
|
50
|
+
**Returns:**
|
|
51
|
+
|
|
52
|
+
[FlowDerivation](./picoflow.flowderivation.md)<!-- --><T>
|
|
53
|
+
|
|
54
|
+
A new instance of [FlowDerivation](./picoflow.flowderivation.md)<!-- -->.
|
|
55
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [effect](./picoflow.effect.md)
|
|
4
|
+
|
|
5
|
+
## effect() function
|
|
6
|
+
|
|
7
|
+
Creates a new reactive effect that executes a side-effect function based on its dependencies.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare function effect(fn: (get: FlowGetter, watch: FlowWatcher) => void): FlowEffect;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
<table><thead><tr><th>
|
|
18
|
+
|
|
19
|
+
Parameter
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
</th><th>
|
|
23
|
+
|
|
24
|
+
Type
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
</th><th>
|
|
28
|
+
|
|
29
|
+
Description
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</th></tr></thead>
|
|
33
|
+
<tbody><tr><td>
|
|
34
|
+
|
|
35
|
+
fn
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</td><td>
|
|
39
|
+
|
|
40
|
+
(get: [FlowGetter](./picoflow.flowgetter.md)<!-- -->, watch: [FlowWatcher](./picoflow.flowwatcher.md)<!-- -->) => void
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
A function that performs side effects. It receives a getter and a watcher function for tracking reactive dependencies.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
</td></tr>
|
|
49
|
+
</tbody></table>
|
|
50
|
+
**Returns:**
|
|
51
|
+
|
|
52
|
+
[FlowEffect](./picoflow.floweffect.md)
|
|
53
|
+
|
|
54
|
+
A new instance of [FlowEffect](./picoflow.floweffect.md)<!-- -->.
|
|
55
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowDerivation](./picoflow.flowderivation.md) > [(constructor)](./picoflow.flowderivation._constructor_.md)
|
|
4
|
+
|
|
5
|
+
## FlowDerivation.(constructor)
|
|
6
|
+
|
|
7
|
+
Creates a new FlowDerivation.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
constructor(compute: (get: FlowGetter, watch: FlowWatcher) => T);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
<table><thead><tr><th>
|
|
18
|
+
|
|
19
|
+
Parameter
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
</th><th>
|
|
23
|
+
|
|
24
|
+
Type
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
</th><th>
|
|
28
|
+
|
|
29
|
+
Description
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</th></tr></thead>
|
|
33
|
+
<tbody><tr><td>
|
|
34
|
+
|
|
35
|
+
compute
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</td><td>
|
|
39
|
+
|
|
40
|
+
(get: [FlowGetter](./picoflow.flowgetter.md)<!-- -->, watch: [FlowWatcher](./picoflow.flowwatcher.md)<!-- -->) => T
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
A function that computes the derived value. It is provided with a getter and a watcher function to access observables and signals dependencies.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
</td></tr>
|
|
49
|
+
</tbody></table>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowDerivation](./picoflow.flowderivation.md) > [get](./picoflow.flowderivation.get.md)
|
|
4
|
+
|
|
5
|
+
## FlowDerivation.get() method
|
|
6
|
+
|
|
7
|
+
Gets the current derived value.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
get(): T;
|
|
13
|
+
```
|
|
14
|
+
**Returns:**
|
|
15
|
+
|
|
16
|
+
T
|
|
17
|
+
|
|
18
|
+
The current computed value.
|
|
19
|
+
|
|
20
|
+
## Remarks
|
|
21
|
+
|
|
22
|
+
This method ensures that the derivation is up-to-date before returning the value.
|
|
23
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowDerivation](./picoflow.flowderivation.md)
|
|
4
|
+
|
|
5
|
+
## FlowDerivation class
|
|
6
|
+
|
|
7
|
+
Represents a reactive derivation whose value is computed based on other reactive signals.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare class FlowDerivation<T> extends FlowObservable<T>
|
|
13
|
+
```
|
|
14
|
+
**Extends:** [FlowObservable](./picoflow.flowobservable.md)<!-- --><T>
|
|
15
|
+
|
|
16
|
+
## Remarks
|
|
17
|
+
|
|
18
|
+
A FlowDerivation automatically tracks its dependencies and recomputes its value when needed.
|
|
19
|
+
|
|
20
|
+
## Constructors
|
|
21
|
+
|
|
22
|
+
<table><thead><tr><th>
|
|
23
|
+
|
|
24
|
+
Constructor
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
</th><th>
|
|
28
|
+
|
|
29
|
+
Modifiers
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</th><th>
|
|
33
|
+
|
|
34
|
+
Description
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
</th></tr></thead>
|
|
38
|
+
<tbody><tr><td>
|
|
39
|
+
|
|
40
|
+
[(constructor)(compute)](./picoflow.flowderivation._constructor_.md)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
</td><td>
|
|
47
|
+
|
|
48
|
+
Creates a new FlowDerivation.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
</td></tr>
|
|
52
|
+
</tbody></table>
|
|
53
|
+
|
|
54
|
+
## Methods
|
|
55
|
+
|
|
56
|
+
<table><thead><tr><th>
|
|
57
|
+
|
|
58
|
+
Method
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
</th><th>
|
|
62
|
+
|
|
63
|
+
Modifiers
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
</th><th>
|
|
67
|
+
|
|
68
|
+
Description
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
</th></tr></thead>
|
|
72
|
+
<tbody><tr><td>
|
|
73
|
+
|
|
74
|
+
[get()](./picoflow.flowderivation.get.md)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
</td><td>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
</td><td>
|
|
81
|
+
|
|
82
|
+
Gets the current derived value.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
</td></tr>
|
|
86
|
+
</tbody></table>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowDisposer](./picoflow.flowdisposer.md)
|
|
4
|
+
|
|
5
|
+
## FlowDisposer type
|
|
6
|
+
|
|
7
|
+
A function that disposes of a resource.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export type FlowDisposer = () => void;
|
|
13
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowEffect](./picoflow.floweffect.md) > [(constructor)](./picoflow.floweffect._constructor_.md)
|
|
4
|
+
|
|
5
|
+
## FlowEffect.(constructor)
|
|
6
|
+
|
|
7
|
+
Creates a new FlowEffect.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
constructor(apply: (get: FlowGetter, watch: FlowWatcher) => void);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
<table><thead><tr><th>
|
|
18
|
+
|
|
19
|
+
Parameter
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
</th><th>
|
|
23
|
+
|
|
24
|
+
Type
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
</th><th>
|
|
28
|
+
|
|
29
|
+
Description
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</th></tr></thead>
|
|
33
|
+
<tbody><tr><td>
|
|
34
|
+
|
|
35
|
+
apply
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</td><td>
|
|
39
|
+
|
|
40
|
+
(get: [FlowGetter](./picoflow.flowgetter.md)<!-- -->, watch: [FlowWatcher](./picoflow.flowwatcher.md)<!-- -->) => void
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
A function that performs the side effect. It receives a getter and a watcher function to access and register dependencies on reactive observables and signals.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
</td></tr>
|
|
49
|
+
</tbody></table>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowEffect](./picoflow.floweffect.md) > [dispose](./picoflow.floweffect.dispose.md)
|
|
4
|
+
|
|
5
|
+
## FlowEffect.dispose() method
|
|
6
|
+
|
|
7
|
+
Disposes the effect, unregistering all its dependencies.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
dispose(): void;
|
|
13
|
+
```
|
|
14
|
+
**Returns:**
|
|
15
|
+
|
|
16
|
+
void
|
|
17
|
+
|
|
18
|
+
## Remarks
|
|
19
|
+
|
|
20
|
+
After disposal, the effect should no longer be used. Calling this method on an already disposed effect will throw an error.
|
|
21
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowEffect](./picoflow.floweffect.md) > [disposed](./picoflow.floweffect.disposed.md)
|
|
4
|
+
|
|
5
|
+
## FlowEffect.disposed property
|
|
6
|
+
|
|
7
|
+
Indicates whether this effect has been disposed.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
get disposed(): boolean;
|
|
13
|
+
```
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowEffect](./picoflow.floweffect.md)
|
|
4
|
+
|
|
5
|
+
## FlowEffect class
|
|
6
|
+
|
|
7
|
+
Represents a reactive effect that executes a side‐effect function based on its tracked dependencies.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare class FlowEffect
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Remarks
|
|
16
|
+
|
|
17
|
+
A FlowEffect runs an apply function to perform side effects. The apply function is executed in two modes: Initially, in a tracked mode to register dependencies. Subsequently, in an untracked mode to only re-execute the effect .
|
|
18
|
+
|
|
19
|
+
## Constructors
|
|
20
|
+
|
|
21
|
+
<table><thead><tr><th>
|
|
22
|
+
|
|
23
|
+
Constructor
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
</th><th>
|
|
27
|
+
|
|
28
|
+
Modifiers
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
</th><th>
|
|
32
|
+
|
|
33
|
+
Description
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
</th></tr></thead>
|
|
37
|
+
<tbody><tr><td>
|
|
38
|
+
|
|
39
|
+
[(constructor)(apply)](./picoflow.floweffect._constructor_.md)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
</td><td>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
</td><td>
|
|
46
|
+
|
|
47
|
+
Creates a new FlowEffect.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
</td></tr>
|
|
51
|
+
</tbody></table>
|
|
52
|
+
|
|
53
|
+
## Properties
|
|
54
|
+
|
|
55
|
+
<table><thead><tr><th>
|
|
56
|
+
|
|
57
|
+
Property
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
</th><th>
|
|
61
|
+
|
|
62
|
+
Modifiers
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
</th><th>
|
|
66
|
+
|
|
67
|
+
Type
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
</th><th>
|
|
71
|
+
|
|
72
|
+
Description
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
</th></tr></thead>
|
|
76
|
+
<tbody><tr><td>
|
|
77
|
+
|
|
78
|
+
[disposed](./picoflow.floweffect.disposed.md)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
</td><td>
|
|
82
|
+
|
|
83
|
+
`readonly`
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
</td><td>
|
|
87
|
+
|
|
88
|
+
boolean
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
</td><td>
|
|
92
|
+
|
|
93
|
+
Indicates whether this effect has been disposed.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
</td></tr>
|
|
97
|
+
</tbody></table>
|
|
98
|
+
|
|
99
|
+
## Methods
|
|
100
|
+
|
|
101
|
+
<table><thead><tr><th>
|
|
102
|
+
|
|
103
|
+
Method
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
</th><th>
|
|
107
|
+
|
|
108
|
+
Modifiers
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
</th><th>
|
|
112
|
+
|
|
113
|
+
Description
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
</th></tr></thead>
|
|
117
|
+
<tbody><tr><td>
|
|
118
|
+
|
|
119
|
+
[dispose()](./picoflow.floweffect.dispose.md)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
</td><td>
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
</td><td>
|
|
126
|
+
|
|
127
|
+
Disposes the effect, unregistering all its dependencies.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
</td></tr>
|
|
131
|
+
</tbody></table>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [picoflow](./picoflow.md) > [FlowGetter](./picoflow.flowgetter.md)
|
|
4
|
+
|
|
5
|
+
## FlowGetter type
|
|
6
|
+
|
|
7
|
+
A function for retrieving the current value from a FlowObservable.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export type FlowGetter = <T>(observable: FlowObservable<T>) => T;
|
|
13
|
+
```
|
|
14
|
+
**References:** [FlowObservable](./picoflow.flowobservable.md)
|
|
15
|
+
|