@planet-matrix/mobius-model 0.1.4 → 0.3.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/CHANGELOG.md +46 -0
- package/README.md +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +12 -6
- package/dist/reactor/index.d.ts +3 -0
- package/dist/reactor/index.d.ts.map +1 -0
- package/dist/reactor/reactor-core/flags.d.ts.map +1 -0
- package/dist/reactor/reactor-core/index.d.ts.map +1 -0
- package/dist/reactor/reactor-core/primitive.d.ts +276 -0
- package/dist/reactor/reactor-core/primitive.d.ts.map +1 -0
- package/dist/{signal/signal-core → reactor/reactor-core}/reactive-system.d.ts +102 -22
- package/dist/reactor/reactor-core/reactive-system.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/branch.d.ts +19 -0
- package/dist/reactor/reactor-operators/branch.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/convert.d.ts +30 -0
- package/dist/reactor/reactor-operators/convert.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/create.d.ts +26 -0
- package/dist/reactor/reactor-operators/create.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/filter.d.ts +269 -0
- package/dist/reactor/reactor-operators/filter.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/index.d.ts +8 -0
- package/dist/reactor/reactor-operators/index.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/join.d.ts +48 -0
- package/dist/reactor/reactor-operators/join.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/map.d.ts +165 -0
- package/dist/reactor/reactor-operators/map.d.ts.map +1 -0
- package/dist/reactor/reactor-operators/utility.d.ts +48 -0
- package/dist/reactor/reactor-operators/utility.d.ts.map +1 -0
- package/package.json +9 -9
- package/src/index.ts +1 -1
- package/src/reactor/README.md +18 -0
- package/src/reactor/index.ts +2 -0
- package/src/reactor/reactor-core/primitive.ts +1046 -0
- package/src/{signal/signal-core → reactor/reactor-core}/reactive-system.ts +392 -93
- package/src/reactor/reactor-operators/branch.ts +66 -0
- package/src/reactor/reactor-operators/convert.ts +70 -0
- package/src/reactor/reactor-operators/create.ts +66 -0
- package/src/reactor/reactor-operators/filter.ts +988 -0
- package/src/reactor/reactor-operators/index.ts +7 -0
- package/src/reactor/reactor-operators/join.ts +174 -0
- package/src/reactor/reactor-operators/map.ts +599 -0
- package/src/reactor/reactor-operators/utility.ts +102 -0
- package/tests/unit/{signal/computed.spec.ts → reactor/alien-signals-computed.spec.ts} +15 -10
- package/tests/unit/reactor/alien-signals-effect-scope.spec.ts +86 -0
- package/tests/unit/reactor/alien-signals-effect.spec.ts +395 -0
- package/tests/unit/reactor/alien-signals-topology.spec.ts +361 -0
- package/tests/unit/reactor/alien-signals-trigger.spec.ts +75 -0
- package/tests/unit/reactor/alien-signals-untrack.spec.ts +91 -0
- package/tests/unit/reactor/preact-signal.spec.ts +73 -0
- package/tests/unit/reactor/reactor-core.spec.ts +219 -0
- package/tests/unit/reactor/reactor-operators-branch.spec.ts +33 -0
- package/tests/unit/reactor/reactor-operators-convert.spec.ts +31 -0
- package/tests/unit/reactor/reactor-operators-create.spec.ts +47 -0
- package/tests/unit/reactor/reactor-operators-filter.spec.ts +604 -0
- package/tests/unit/reactor/reactor-operators-join.spec.ts +94 -0
- package/tests/unit/reactor/reactor-operators-map.spec.ts +327 -0
- package/tests/unit/reactor/reactor-operators-utility.spec.ts +55 -0
- package/dist/signal/index.d.ts +0 -3
- package/dist/signal/index.d.ts.map +0 -1
- package/dist/signal/signal-core/flags.d.ts.map +0 -1
- package/dist/signal/signal-core/index.d.ts.map +0 -1
- package/dist/signal/signal-core/primitive.d.ts +0 -67
- package/dist/signal/signal-core/primitive.d.ts.map +0 -1
- package/dist/signal/signal-core/reactive-system.d.ts.map +0 -1
- package/dist/signal/signal-operators/index.d.ts +0 -4
- package/dist/signal/signal-operators/index.d.ts.map +0 -1
- package/src/signal/index.ts +0 -2
- package/src/signal/signal-core/README.md +0 -4
- package/src/signal/signal-core/primitive.ts +0 -275
- package/src/signal/signal-operators/index.ts +0 -19
- package/tests/unit/signal/effect.spec.ts +0 -108
- /package/dist/{signal/signal-core → reactor/reactor-core}/flags.d.ts +0 -0
- /package/dist/{signal/signal-core → reactor/reactor-core}/index.d.ts +0 -0
- /package/src/{signal/signal-core → reactor/reactor-core}/flags.ts +0 -0
- /package/src/{signal/signal-core → reactor/reactor-core}/index.ts +0 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import type { Signal, SignalValueInitializer, ValueReactor } from "../reactor-core/index.ts";
|
|
2
|
+
export interface CurrentOptions<V> {
|
|
3
|
+
target: ValueReactor<V>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns a Signal that holds the current value of the target ValueReactor.
|
|
7
|
+
*/
|
|
8
|
+
export declare const current: <V>(options: CurrentOptions<V>) => Signal<V>;
|
|
9
|
+
export interface NextOptions<V> {
|
|
10
|
+
target: ValueReactor<V>;
|
|
11
|
+
valueInitializer: SignalValueInitializer<V>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns a Signal that holds the next value of the target ValueReactor
|
|
15
|
+
* after the initial value.
|
|
16
|
+
*
|
|
17
|
+
* The Signal will update its value only once, upon the next change of
|
|
18
|
+
* the target ValueReactor, and then it will not update anymore.
|
|
19
|
+
*/
|
|
20
|
+
export declare const next: <V>(options: NextOptions<V>) => Signal<V>;
|
|
21
|
+
export interface FilterInitializingFalsyValueGetterContext<V> {
|
|
22
|
+
isInitializingRun: true;
|
|
23
|
+
targetValue: V;
|
|
24
|
+
}
|
|
25
|
+
export interface FilterUpdatingFalsyValueGetterContext<V> {
|
|
26
|
+
isInitializingRun: false;
|
|
27
|
+
targetValue: V;
|
|
28
|
+
previousValue: V;
|
|
29
|
+
}
|
|
30
|
+
export type FilterFalsyValueGetterContextOf<V> = FilterInitializingFalsyValueGetterContext<V> | FilterUpdatingFalsyValueGetterContext<V>;
|
|
31
|
+
export interface FilterOptions<V> {
|
|
32
|
+
target: ValueReactor<V>;
|
|
33
|
+
truthyPredicate: (value: V) => boolean;
|
|
34
|
+
falsyValueGetter: (context: FilterFalsyValueGetterContextOf<V>) => V;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns a Signal that only updates its value from the target
|
|
38
|
+
* ValueReactor when the predicate function returns true.
|
|
39
|
+
*/
|
|
40
|
+
export declare const filter: <V>(options: FilterOptions<V>) => Signal<V>;
|
|
41
|
+
export interface AuditByCountOptions<V> {
|
|
42
|
+
target: ValueReactor<V>;
|
|
43
|
+
count: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns a Signal that updates its value with the latest value from
|
|
47
|
+
* the target ValueReactor after every specified count of emissions.
|
|
48
|
+
*/
|
|
49
|
+
export declare const auditByCount: <V>(options: AuditByCountOptions<V>) => Signal<V>;
|
|
50
|
+
export interface AuditByTimeOptions<V> {
|
|
51
|
+
target: ValueReactor<V>;
|
|
52
|
+
time: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns a Signal that updates its value with the latest value from
|
|
56
|
+
* the target ValueReactor at specified time intervals.
|
|
57
|
+
*/
|
|
58
|
+
export declare const auditByTime: <V>(options: AuditByTimeOptions<V>) => Signal<V>;
|
|
59
|
+
export interface AuditByTriggerOptions<VTarget, VTrigger> {
|
|
60
|
+
target: ValueReactor<VTarget>;
|
|
61
|
+
trigger: ValueReactor<VTrigger>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns a Signal that only updates its value when the trigger
|
|
65
|
+
* ValueReactor emits a value, using the latest value from the target
|
|
66
|
+
* ValueReactor.
|
|
67
|
+
*/
|
|
68
|
+
export declare const auditByTrigger: <VTarget, VTrigger>(options: AuditByTriggerOptions<VTarget, VTrigger>) => Signal<VTarget>;
|
|
69
|
+
export interface AuditByToggleOptions<VTarget, VOpen, VClose> {
|
|
70
|
+
target: ValueReactor<VTarget>;
|
|
71
|
+
open: ValueReactor<VOpen>;
|
|
72
|
+
close: ValueReactor<VClose>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns a Signal that updates its value with the latest value from
|
|
76
|
+
* the target ValueReactor when the close ValueReactor emits, but only
|
|
77
|
+
* if auditing was started by the open ValueReactor.
|
|
78
|
+
*/
|
|
79
|
+
export declare const auditByToggle: <VTarget, VOpen, VClose>(options: AuditByToggleOptions<VTarget, VOpen, VClose>) => Signal<VTarget>;
|
|
80
|
+
export interface AuditByDynamicOptions<VTarget, VDynamic> {
|
|
81
|
+
target: ValueReactor<VTarget>;
|
|
82
|
+
dynamic: (value: VTarget) => ValueReactor<VDynamic>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns a Signal that updates its value with the latest value from
|
|
86
|
+
* the target ValueReactor when the ValueReactor returned by the `dynamic`
|
|
87
|
+
* function emits. The `dynamic` function is called each time after emitting
|
|
88
|
+
* to get a new ValueReactor for the next audit period.
|
|
89
|
+
*/
|
|
90
|
+
export declare const auditByDynamic: <VTarget, VDynamic>(options: AuditByDynamicOptions<VTarget, VDynamic>) => Signal<VTarget>;
|
|
91
|
+
export interface DebounceByCountOptions<V> {
|
|
92
|
+
target: ValueReactor<V>;
|
|
93
|
+
count: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns a Signal that updates its value with the latest value from
|
|
97
|
+
* the target ValueReactor after the specified count of emissions
|
|
98
|
+
* without being updated.
|
|
99
|
+
*/
|
|
100
|
+
export declare const debounceByCount: <V>(options: DebounceByCountOptions<V>) => Signal<V>;
|
|
101
|
+
export interface DebounceByTimeOptions<V> {
|
|
102
|
+
target: ValueReactor<V>;
|
|
103
|
+
time: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Returns a Signal that updates its value with the latest value from
|
|
107
|
+
* the target ValueReactor after the specified time in milliseconds
|
|
108
|
+
* has passed since the last update.
|
|
109
|
+
*/
|
|
110
|
+
export declare const debounceByTime: <V>(options: DebounceByTimeOptions<V>) => Signal<V>;
|
|
111
|
+
export interface DebounceByTriggerOptions<VTarget, VTrigger> {
|
|
112
|
+
target: ValueReactor<VTarget>;
|
|
113
|
+
trigger: ValueReactor<VTrigger>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns a Signal that updates its value with the latest value from
|
|
117
|
+
* the target ValueReactor whenever the trigger ValueReactor
|
|
118
|
+
* emits a value.
|
|
119
|
+
*/
|
|
120
|
+
export declare const debounceByTrigger: <VTarget, VTrigger>(options: DebounceByTriggerOptions<VTarget, VTrigger>) => Signal<VTarget>;
|
|
121
|
+
export interface DebounceByToggleOptions<VTarget, VOpen, VClose> {
|
|
122
|
+
target: ValueReactor<VTarget>;
|
|
123
|
+
open: ValueReactor<VOpen>;
|
|
124
|
+
close: ValueReactor<VClose>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns a Signal that updates its value with the latest value from
|
|
128
|
+
* the target ValueReactor when the close ValueReactor emits, but only
|
|
129
|
+
* if debouncing was started by the open ValueReactor.
|
|
130
|
+
*/
|
|
131
|
+
export declare const debounceByToggle: <VTarget, VOpen, VClose>(options: DebounceByToggleOptions<VTarget, VOpen, VClose>) => Signal<VTarget>;
|
|
132
|
+
export interface DebounceByDynamicOptions<VTarget, VDynamic> {
|
|
133
|
+
target: ValueReactor<VTarget>;
|
|
134
|
+
dynamic: (value: VTarget) => ValueReactor<VDynamic>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Returns a Signal that updates its value with the latest value from
|
|
138
|
+
* the target ValueReactor when the ValueReactor returned by the `dynamic`
|
|
139
|
+
* function emits. The `dynamic` function is called each time after emitting
|
|
140
|
+
* to get a new ValueReactor for the next debounce period.
|
|
141
|
+
*/
|
|
142
|
+
export declare const debounceByDynamic: <VTarget, VDynamic>(options: DebounceByDynamicOptions<VTarget, VDynamic>) => Signal<VTarget>;
|
|
143
|
+
export interface ThrottleByCountOptions<V> {
|
|
144
|
+
target: ValueReactor<V>;
|
|
145
|
+
count: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns a Signal that updates its value with the latest value from
|
|
149
|
+
* the target ValueReactor at most once every specified count of emissions.
|
|
150
|
+
*/
|
|
151
|
+
export declare const throttleByCount: <V>(options: ThrottleByCountOptions<V>) => Signal<V>;
|
|
152
|
+
export interface ThrottleByTimeOptions<V> {
|
|
153
|
+
target: ValueReactor<V>;
|
|
154
|
+
time: number;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Returns a Signal that updates its value with the latest value from
|
|
158
|
+
* the target ValueReactor at most once every specified time in milliseconds.
|
|
159
|
+
*/
|
|
160
|
+
export declare const throttleByTime: <V>(options: ThrottleByTimeOptions<V>) => Signal<V>;
|
|
161
|
+
export interface ThrottleByTriggerOptions<VTarget, VTrigger> {
|
|
162
|
+
target: ValueReactor<VTarget>;
|
|
163
|
+
trigger: ValueReactor<VTrigger>;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns a Signal that updates its value with the latest value from
|
|
167
|
+
* the target ValueReactor at most once whenever the trigger
|
|
168
|
+
* ValueReactor emits.
|
|
169
|
+
*/
|
|
170
|
+
export declare const throttleByTrigger: <VTarget, VTrigger>(options: ThrottleByTriggerOptions<VTarget, VTrigger>) => Signal<VTarget>;
|
|
171
|
+
export interface ThrottleByToggleOptions<VTarget, VOpen, VClose> {
|
|
172
|
+
target: ValueReactor<VTarget>;
|
|
173
|
+
open: ValueReactor<VOpen>;
|
|
174
|
+
close: ValueReactor<VClose>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns a Signal that updates its value with the latest value from
|
|
178
|
+
* the target ValueReactor when the close ValueReactor emits, but only
|
|
179
|
+
* if throttling was started by the open ValueReactor.
|
|
180
|
+
*/
|
|
181
|
+
export declare const throttleByToggle: <VTarget, VOpen, VClose>(options: ThrottleByToggleOptions<VTarget, VOpen, VClose>) => Signal<VTarget>;
|
|
182
|
+
export interface ThrottleByDynamicOptions<VTarget, VDynamic> {
|
|
183
|
+
target: ValueReactor<VTarget>;
|
|
184
|
+
dynamic: (value: VTarget) => ValueReactor<VDynamic>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Returns a Signal that updates its value with the latest value from
|
|
188
|
+
* the target ValueReactor when the ValueReactor returned by the `dynamic`
|
|
189
|
+
* function emits. The `dynamic` function is called each time after emitting
|
|
190
|
+
* to get a new ValueReactor for the next throttle period.
|
|
191
|
+
*/
|
|
192
|
+
export declare const throttleByDynamic: <VTarget, VDynamic>(options: ThrottleByDynamicOptions<VTarget, VDynamic>) => Signal<VTarget>;
|
|
193
|
+
export interface DistinctOptions<V, K> {
|
|
194
|
+
target: ValueReactor<V>;
|
|
195
|
+
keyGetter?: (value: V) => K;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Returns a Signal that only updates its value with unique values
|
|
199
|
+
* from the target ValueReactor, determined by the key returned from
|
|
200
|
+
* the keyGetter function.
|
|
201
|
+
*/
|
|
202
|
+
export declare const distinct: <V, K>(options: DistinctOptions<V, K>) => Signal<V>;
|
|
203
|
+
export interface DistinctUntilChangedOptions<V, K> {
|
|
204
|
+
target: ValueReactor<V>;
|
|
205
|
+
keyGetter?: (value: V) => K;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Returns a Signal that only updates its value when the key returned
|
|
209
|
+
* from the keyGetter function changes between emissions.
|
|
210
|
+
*/
|
|
211
|
+
export declare const distinctUntilChanged: <V, K>(options: DistinctUntilChangedOptions<V, K>) => Signal<V>;
|
|
212
|
+
export interface TakeByPredicateOptions<V> {
|
|
213
|
+
target: ValueReactor<V>;
|
|
214
|
+
predicate: (value: V) => boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Returns a Signal that updates its value with the latest value from
|
|
218
|
+
* the target ValueReactor, but only while the predicate function
|
|
219
|
+
* returns true.
|
|
220
|
+
*/
|
|
221
|
+
export declare const takeByPredicate: <V>(options: TakeByPredicateOptions<V>) => Signal<V>;
|
|
222
|
+
export interface TakeByCountOptions<V> {
|
|
223
|
+
target: ValueReactor<V>;
|
|
224
|
+
count: number;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Returns a Signal that updates its value with the latest value from
|
|
228
|
+
* the target ValueReactor, but only for the first `count` emissions.
|
|
229
|
+
*/
|
|
230
|
+
export declare const takeByCount: <V>(options: TakeByCountOptions<V>) => Signal<V>;
|
|
231
|
+
export interface TakeByTimeOptions<T> {
|
|
232
|
+
target: ValueReactor<T>;
|
|
233
|
+
time: number;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns a Signal that updates its value with the latest value from
|
|
237
|
+
* the target ValueReactor, but only for the specified time in milliseconds.
|
|
238
|
+
*/
|
|
239
|
+
export declare const takeByTime: <T>(options: TakeByTimeOptions<T>) => Signal<T>;
|
|
240
|
+
export interface TakeByTriggerOptions<VTarget, VTrigger> {
|
|
241
|
+
target: ValueReactor<VTarget>;
|
|
242
|
+
trigger: ValueReactor<VTrigger>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Returns a Signal that updates its value with the latest value from
|
|
246
|
+
* the target ValueReactor whenever the trigger ValueReactor emits a value.
|
|
247
|
+
*/
|
|
248
|
+
export declare const takeByTrigger: <VTarget, VTrigger>(options: TakeByTriggerOptions<VTarget, VTrigger>) => Signal<VTarget>;
|
|
249
|
+
export interface TakeByToggleOptions<VTarget, VOpen, VClose> {
|
|
250
|
+
target: ValueReactor<VTarget>;
|
|
251
|
+
open: ValueReactor<VOpen>;
|
|
252
|
+
close: ValueReactor<VClose>;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Returns a Signal that updates its value with the latest value from
|
|
256
|
+
* the target ValueReactor when the close ValueReactor emits, but only
|
|
257
|
+
* if taking was started by the open ValueReactor.
|
|
258
|
+
*/
|
|
259
|
+
export declare const takeByToggle: <VTarget, VOpen, VClose>(options: TakeByToggleOptions<VTarget, VOpen, VClose>) => Signal<VTarget>;
|
|
260
|
+
export interface TakeUntilTriggerOptions<VTarget, VTrigger> {
|
|
261
|
+
target: ValueReactor<VTarget>;
|
|
262
|
+
trigger: ValueReactor<VTrigger>;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Returns a Signal that updates its value with the latest value from
|
|
266
|
+
* the target ValueReactor until the trigger ValueReactor emits a value.
|
|
267
|
+
*/
|
|
268
|
+
export declare const takeUntilTrigger: <VTarget, VTrigger>(options: TakeUntilTriggerOptions<VTarget, VTrigger>) => Signal<VTarget>;
|
|
269
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/reactor/reactor-operators/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAK5F,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CACzB;AACD;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,0CAUxB,CAAA;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,gBAAgB,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAA;CAC5C;AACD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,uCAsBrB,CAAA;AAED,MAAM,WAAW,yCAAyC,CAAC,CAAC;IAC1D,iBAAiB,EAAE,IAAI,CAAC;IACxB,WAAW,EAAE,CAAC,CAAA;CACf;AACD,MAAM,WAAW,qCAAqC,CAAC,CAAC;IACtD,iBAAiB,EAAE,KAAK,CAAC;IACzB,WAAW,EAAE,CAAC,CAA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type { AnyValueReactorArray, AnyValueReactorObject, GetValuesInArray, GetValuesInObject } from "./utility.ts";
|
|
2
|
+
import type { Signal, ValueReactor } from "../reactor-core/index.ts";
|
|
3
|
+
export type CombineLatestArray<T extends AnyValueReactorArray> = Signal<GetValuesInArray<T>>;
|
|
4
|
+
export interface CombineLatestArrayOptions<T extends AnyValueReactorArray> {
|
|
5
|
+
target: T;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Combines multiple ValueReactors into a Signal that emits the latest values
|
|
9
|
+
* from each ValueReactor whenever any of them updates.
|
|
10
|
+
*/
|
|
11
|
+
export declare const combineLatestArray: <T extends AnyValueReactorArray>(options: CombineLatestArrayOptions<T>) => CombineLatestArray<T>;
|
|
12
|
+
export type CombineLatestObject<T extends AnyValueReactorObject> = Signal<GetValuesInObject<T>>;
|
|
13
|
+
export interface CombineLatestObjectOptions<T extends AnyValueReactorObject> {
|
|
14
|
+
target: T;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Combines multiple ValueReactors in an object into a Signal that emits the latest values
|
|
18
|
+
* from each ValueReactor whenever any of them updates.
|
|
19
|
+
*/
|
|
20
|
+
export declare const combineLatestObject: <T extends AnyValueReactorObject>(options: CombineLatestObjectOptions<T>) => CombineLatestObject<T>;
|
|
21
|
+
export type MergeArray<T extends AnyValueReactorArray> = Signal<GetValuesInArray<T>[number]>;
|
|
22
|
+
export interface MergeArrayOptions<T extends AnyValueReactorArray> {
|
|
23
|
+
target: T;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Merges multiple ValueReactors into a Signal that emits values
|
|
27
|
+
* from any of the ValueReactors as they update.
|
|
28
|
+
*/
|
|
29
|
+
export declare const mergeArray: <T extends AnyValueReactorArray>(options: MergeArrayOptions<T>) => MergeArray<T>;
|
|
30
|
+
export interface WithLatestFromOptions<T, U> {
|
|
31
|
+
target: ValueReactor<T>;
|
|
32
|
+
other: ValueReactor<U>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Combines two ValueReactors into a Signal that emits the latest values
|
|
36
|
+
* from the source ValueReactor along with the latest value from the other ValueReactor.
|
|
37
|
+
*/
|
|
38
|
+
export declare const withLatestFrom: <T, U>(options: WithLatestFromOptions<T, U>) => Signal<[T, U]>;
|
|
39
|
+
export interface ZipOptions<VA, VB> {
|
|
40
|
+
a: ValueReactor<VA>;
|
|
41
|
+
b: ValueReactor<VB>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Zips two ValueReactors into a Signal that emits pairs of values.
|
|
45
|
+
* Each time both ValueReactors have new values, a new pair is emitted.
|
|
46
|
+
*/
|
|
47
|
+
export declare const zip: <VA, VB>(options: ZipOptions<VA, VB>) => Signal<[VA, VB]>;
|
|
48
|
+
//# sourceMappingURL=join.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../src/reactor/reactor-operators/join.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACpH,OAAO,KAAK,EAAU,MAAM,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAK5E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,oBAAoB,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7F,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,oBAAoB;IACvE,MAAM,EAAE,CAAC,CAAC;CACX;AACD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,8FAgBnC,CAAA;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,qBAAqB,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAChG,MAAM,WAAW,0BAA0B,CAAC,CAAC,SAAS,qBAAqB;IACzE,MAAM,EAAE,CAAC,CAAC;CACX;AACD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,iGAgBpC,CAAA;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,oBAAoB,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7F,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,oBAAoB;IAC/D,MAAM,EAAE,CAAC,CAAC;CACX;AACD;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,8EAwB3B,CAAA;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,EAAE,CAAC;IACzC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CACxB;AACD;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,yDAuBlC,CAAA;AAED,MAAM,WAAW,UAAU,CAAC,EAAE,EAAE,EAAE;IAChC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;CACrB;AACD;;;GAGG;AACH,eAAO,MAAM,GAAG,GAAI,EAAE,EAAE,EAAE,kDAwCzB,CAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { AnyValueReactor, Signal, ValueOfValueReactor, ValueReactor } from "../reactor-core/index.ts";
|
|
2
|
+
export interface TapOptions<R extends AnyValueReactor> {
|
|
3
|
+
target: R;
|
|
4
|
+
tapper?: ((value: ValueOfValueReactor<R>) => void) | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Taps into the value changes of a ValueReactor without modifying its value.
|
|
8
|
+
*/
|
|
9
|
+
export declare const tap: <R extends AnyValueReactor>(options: TapOptions<R>) => R;
|
|
10
|
+
export interface WithHistoryOptions<V> {
|
|
11
|
+
target: ValueReactor<V>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a signal that maintains a history of values from a ValueReactor.
|
|
15
|
+
* The history is stored in an array, with each new value appended to the end.
|
|
16
|
+
*
|
|
17
|
+
* Note: This implementation does not limit the size of the history array. Use
|
|
18
|
+
* with caution to avoid excessive memory usage.
|
|
19
|
+
*/
|
|
20
|
+
export declare const withHistory: <V>(options: WithHistoryOptions<V>) => Signal<V[]>;
|
|
21
|
+
export interface BufferByCountOptions<V> {
|
|
22
|
+
target: ValueReactor<V>;
|
|
23
|
+
count: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Buffers values from a ValueReactor and emits them as an array
|
|
27
|
+
* when the number of buffered values reaches the specified count.
|
|
28
|
+
*/
|
|
29
|
+
export declare const bufferByCount: <V>(options: BufferByCountOptions<V>) => Signal<V[]>;
|
|
30
|
+
export interface BufferByTimeOptions<V> {
|
|
31
|
+
target: ValueReactor<V>;
|
|
32
|
+
time: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Buffers values from a ValueReactor and emits them as an array
|
|
36
|
+
* at specified time intervals.
|
|
37
|
+
*/
|
|
38
|
+
export declare const bufferByTime: <V>(options: BufferByTimeOptions<V>) => Signal<V[]>;
|
|
39
|
+
export interface BufferByTriggerOptions<VTarget, VTrigger> {
|
|
40
|
+
target: ValueReactor<VTarget>;
|
|
41
|
+
trigger: ValueReactor<VTrigger>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Buffers values from a ValueReactor and emits them as an array when the trigger ValueReactor changes.
|
|
45
|
+
*/
|
|
46
|
+
export declare const bufferByTrigger: <VTarget, VTrigger>(options: BufferByTriggerOptions<VTarget, VTrigger>) => Signal<VTarget[]>;
|
|
47
|
+
export interface BufferByToggleOptions<VTarget, VOpen, VClose> {
|
|
48
|
+
target: ValueReactor<VTarget>;
|
|
49
|
+
open: ValueReactor<VOpen>;
|
|
50
|
+
close: ValueReactor<VClose>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Buffers values from a ValueReactor and emits them as an array
|
|
54
|
+
* when the open ValueReactor emits a value, and stops buffering
|
|
55
|
+
* when the close ValueReactor emits a value.
|
|
56
|
+
*/
|
|
57
|
+
export declare const bufferByToggle: <VTarget, VOpen, VClose>(options: BufferByToggleOptions<VTarget, VOpen, VClose>) => Signal<VTarget[]>;
|
|
58
|
+
export interface BufferByDynamicOptions<VTarget, VDynamic> {
|
|
59
|
+
target: ValueReactor<VTarget>;
|
|
60
|
+
dynamic: (value: VTarget) => ValueReactor<VDynamic>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Buffers values from a ValueReactor and emits them as an array
|
|
64
|
+
* when the ValueReactor returned by the `dynamic` function emits a value.
|
|
65
|
+
* The `dynamic` function is called each time the buffer is emitted
|
|
66
|
+
* to get a new ValueReactor for the next buffer.
|
|
67
|
+
*/
|
|
68
|
+
export declare const bufferByDynamic: <VTarget, VDynamic>(options: BufferByDynamicOptions<VTarget, VDynamic>) => Signal<VTarget[]>;
|
|
69
|
+
export interface GroupToArrayByOptions<V, K> {
|
|
70
|
+
target: ValueReactor<V>;
|
|
71
|
+
keyGetter: (value: V) => K;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Groups values from a ValueReactor into an array of arrays based on a key
|
|
75
|
+
* extracted by the keyGetter function.
|
|
76
|
+
*/
|
|
77
|
+
export declare const groupToArrayBy: <V, K>(options: GroupToArrayByOptions<V, K>) => Signal<V[][]>;
|
|
78
|
+
export interface GroupToObjectByOptions<V, K extends string | number | symbol> {
|
|
79
|
+
target: ValueReactor<V>;
|
|
80
|
+
keyGetter: (value: V) => K;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Groups values from a ValueReactor into an object where each key maps to an array
|
|
84
|
+
* of values corresponding to that key.
|
|
85
|
+
*/
|
|
86
|
+
export declare const groupToObjectBy: <V, K extends string | number | symbol>(options: GroupToObjectByOptions<V, K>) => Signal<Record<K, V[]>>;
|
|
87
|
+
/**
|
|
88
|
+
* Groups values from a ValueReactor into an array of Signals based on a key
|
|
89
|
+
* extracted by the keyGetter function.
|
|
90
|
+
*/
|
|
91
|
+
export declare const groupToSignalArrayBy: <V, K>(target: ValueReactor<V>, keyGetter: (value: V) => K) => Signal<Signal<V[]>[]>;
|
|
92
|
+
export interface GroupToSignalObjectByOptions<V, K extends string | number | symbol> {
|
|
93
|
+
target: ValueReactor<V>;
|
|
94
|
+
keyGetter: (value: V) => K;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Groups values from a ValueReactor into a Signal of an object where each key maps to a Signal
|
|
98
|
+
* of an array of values corresponding to that key.
|
|
99
|
+
*/
|
|
100
|
+
export declare const groupToSignalObjectBy: <V, K extends string | number | symbol>(options: GroupToSignalObjectByOptions<V, K>) => Signal<Record<K, Signal<V[]>>>;
|
|
101
|
+
export interface MapOptions<VTarget, VMapped> {
|
|
102
|
+
target: ValueReactor<VTarget>;
|
|
103
|
+
mapper: (value: VTarget) => VMapped;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Maps values from a ValueReactor using the provided mapper function and
|
|
107
|
+
* emits the mapped values as a new Signal.
|
|
108
|
+
*/
|
|
109
|
+
export declare const map: <VTarget, VMapped>(options: MapOptions<VTarget, VMapped>) => Signal<VMapped>;
|
|
110
|
+
export interface ContextualMapInitializingMapperContext<VTarget> {
|
|
111
|
+
isInitializingRun: true;
|
|
112
|
+
targetValue: VTarget;
|
|
113
|
+
}
|
|
114
|
+
export interface ContextualMapUpdatingMapperContext<VTarget, VMapped> {
|
|
115
|
+
isInitializingRun: false;
|
|
116
|
+
targetValue: VTarget;
|
|
117
|
+
previousMappedValue: VMapped;
|
|
118
|
+
}
|
|
119
|
+
export type ContextualMapMapperContextOf<VTarget, VMapped> = ContextualMapInitializingMapperContext<VTarget> | ContextualMapUpdatingMapperContext<VTarget, VMapped>;
|
|
120
|
+
export interface ContextualMapOptions<VTarget, VMapped> {
|
|
121
|
+
target: ValueReactor<VTarget>;
|
|
122
|
+
mapper: (context: ContextualMapMapperContextOf<VTarget, VMapped>) => VMapped;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Maps values from a ValueReactor using the provided contextual mapper function and
|
|
126
|
+
* emits the mapped values as a new Signal.
|
|
127
|
+
*/
|
|
128
|
+
export declare const contextualMap: <VTarget, VMapped>(options: ContextualMapOptions<VTarget, VMapped>) => Signal<VMapped>;
|
|
129
|
+
export interface MergeMapOptions<VTarget, VMapped> {
|
|
130
|
+
target: ValueReactor<VTarget>;
|
|
131
|
+
mapper: (value: VTarget) => ValueReactor<VMapped>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Maps each value from a ValueReactor<T> to a ValueReactor<R> using the provided `mapper`,
|
|
135
|
+
* subscribes to every mapped reactor, and merges their emitted values into a single `Signal<R>`.
|
|
136
|
+
*/
|
|
137
|
+
export declare const mergeMap: <VTarget, VMapped>(options: MergeMapOptions<VTarget, VMapped>) => Signal<VMapped>;
|
|
138
|
+
export interface SwitchMapOptions<VTarget, VMapped> {
|
|
139
|
+
target: ValueReactor<VTarget>;
|
|
140
|
+
mapper: (value: VTarget) => ValueReactor<VMapped>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Maps each value from a ValueReactor<T> to a ValueReactor<R> using the provided `mapper`,
|
|
144
|
+
* subscribes only to the latest mapped reactor, and emits its values as a `Signal<R>`.
|
|
145
|
+
*/
|
|
146
|
+
export declare const switchMap: <VTarget, VMapped>(options: SwitchMapOptions<VTarget, VMapped>) => Signal<VMapped>;
|
|
147
|
+
export interface ScanOptions<VTarget, VAccumulated> {
|
|
148
|
+
target: ValueReactor<VTarget>;
|
|
149
|
+
accumulator: (acc: VAccumulated, value: VTarget) => VAccumulated;
|
|
150
|
+
seed: VAccumulated;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Accumulates values from a ValueReactor using the provided accumulator function
|
|
154
|
+
* and emits the accumulated value as a Signal.
|
|
155
|
+
*/
|
|
156
|
+
export declare const scan: <VTarget, VAccumulated>(options: ScanOptions<VTarget, VAccumulated>) => Signal<VAccumulated>;
|
|
157
|
+
export interface PairwiseOptions<V> {
|
|
158
|
+
target: ValueReactor<V>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Emits the previous and current values from a ValueReactor as a tuple.
|
|
162
|
+
* The first emitted tuple will have `undefined` as the previous value.
|
|
163
|
+
*/
|
|
164
|
+
export declare const pairwise: <V>(options: PairwiseOptions<V>) => Signal<[V | undefined, V]>;
|
|
165
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/reactor/reactor-operators/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAK1G,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,eAAe;IACnD,MAAM,EAAE,CAAC,CAAC;IACV,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAChE;AACD;;GAEG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,sDAYpB,CAAA;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CACzB;AACD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,gDAkB5B,CAAA;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AACD;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,kDAyB9B,CAAA;AAED,MAAM,WAAW,mB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C,4DAmBzB,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ValueReactor } from "../reactor-core/index.ts";
|
|
2
|
+
export type ValueInitializer<V> = () => V;
|
|
3
|
+
/**
|
|
4
|
+
* This initializer can be used to create a Signal with an undefined initial value which
|
|
5
|
+
* is casted to the desired type T. So the real value getter function will not be called
|
|
6
|
+
* until the Signal is actually used.
|
|
7
|
+
*
|
|
8
|
+
* Every signal should always have a valid value (or value getter which returns a valid value).
|
|
9
|
+
* When using the castValueInitializer, the real value should be set as soon as possible.
|
|
10
|
+
*/
|
|
11
|
+
export declare const castValueInitializer: <V>() => ValueInitializer<V>;
|
|
12
|
+
export type Unsubscribe = () => void;
|
|
13
|
+
export interface SubscribeOptions<V> {
|
|
14
|
+
target: ValueReactor<V>;
|
|
15
|
+
subscriber: (value: V) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Subscribes to a ValueReactor and invokes the subscriber when the reactor's value
|
|
19
|
+
* changes.
|
|
20
|
+
*
|
|
21
|
+
* The initial value is skipped; the subscriber is called only on subsequent updates.
|
|
22
|
+
*/
|
|
23
|
+
export declare const subscribe: <V>(options: SubscribeOptions<V>) => Unsubscribe;
|
|
24
|
+
export type AnyValueReactorArray = Array<ValueReactor<any>>;
|
|
25
|
+
export type GetValuesInArray<T extends AnyValueReactorArray> = {
|
|
26
|
+
[K in keyof T]: T[K] extends ValueReactor<infer U> ? U : never;
|
|
27
|
+
};
|
|
28
|
+
export interface GetValuesInArrayOptions<T extends AnyValueReactorArray> {
|
|
29
|
+
target: T;
|
|
30
|
+
withoutTrack?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the current values from an array of ValueReactors.
|
|
34
|
+
*/
|
|
35
|
+
export declare const getValuesInArray: <T extends AnyValueReactorArray>(options: GetValuesInArrayOptions<T>) => GetValuesInArray<T>;
|
|
36
|
+
export type AnyValueReactorObject = Record<string, ValueReactor<any>>;
|
|
37
|
+
export type GetValuesInObject<T extends AnyValueReactorObject> = {
|
|
38
|
+
[K in keyof T]: T[K] extends ValueReactor<infer U> ? U : never;
|
|
39
|
+
};
|
|
40
|
+
export interface GetValueInObjectOptions<T extends AnyValueReactorObject> {
|
|
41
|
+
target: T;
|
|
42
|
+
withoutTrack?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets the current values from an object of ValueReactors.
|
|
46
|
+
*/
|
|
47
|
+
export declare const getValuesInObject: <T extends AnyValueReactorObject>(options: GetValueInObjectOptions<T>) => GetValuesInObject<T>;
|
|
48
|
+
//# sourceMappingURL=utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../src/reactor/reactor-operators/utility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAI5D,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAC1C;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,0BAKrC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAA;AACpC,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAChC;AACD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,8CAgB1B,CAAA;AAGD,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,oBAAoB,IAAI;KAC5D,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAC/D,CAAA;AACD,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,oBAAoB;IACrE,MAAM,EAAE,CAAC,CAAC;IACV,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AACD;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,0FAWjC,CAAA;AAGD,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,IAAI;KAC9D,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAC/D,CAAA;AACD,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,qBAAqB;IACtE,MAAM,EAAE,CAAC,CAAC;IACV,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AACD;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,4FAelC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planet-matrix/mobius-model",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Mobius model.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mobius",
|
|
@@ -60,14 +60,14 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@planet-matrix/mobius-mono": "0.
|
|
64
|
-
"@types/bun": "^1.3.
|
|
65
|
-
"oxlint": "^1.
|
|
66
|
-
"oxlint-tsgolint": "^0.
|
|
67
|
-
"typescript": "^5.9.
|
|
68
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
69
|
-
"vite": "^7.
|
|
70
|
-
"vitest": "^4.0.
|
|
63
|
+
"@planet-matrix/mobius-mono": "0.6.0",
|
|
64
|
+
"@types/bun": "^1.3.8",
|
|
65
|
+
"oxlint": "^1.42.0",
|
|
66
|
+
"oxlint-tsgolint": "^0.11.4",
|
|
67
|
+
"typescript": "^5.9.3",
|
|
68
|
+
"@typescript/native-preview": "^7.0.0-dev.20260130.1",
|
|
69
|
+
"vite": "^7.3.1",
|
|
70
|
+
"vitest": "^4.0.18"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {},
|
|
73
73
|
"peerDependenciesMeta": {},
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * as Reactor from "./reactor/index.ts"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Reactor
|
|
2
|
+
|
|
3
|
+
Reactor 的实现与以下项目有关:
|
|
4
|
+
|
|
5
|
+
- [alien-signals](https://github.com/stackblitz/alien-signals): Reactor 源于该项目,是在对该项目进行重构的基础上添加了其它个性化实现得到的,两者核心区别包括:1、alien-signals 的 API 更加“函数式”,而 Reactor 的 API 更加“对象式”;2、alien-signals 的源码更注重性能,因而比较晦涩,而 Reactor 的实现更注重可维护性与可扩展性因而比较易懂;3、alien-signals 的功能更单一更克制,几乎只提供了核心的响应式算法,而 Reactor 则提供了更多的相关功能与工具函数。
|
|
6
|
+
- [Preact signals](https://github.com/preactjs/signals):受该项目启发,Reactor 补充了一些额外能力,包括但不限于 `options parameter`、`signal.getWithoutTrack()`(同 `signal.peek()`)、`batch()`、`withoutTracking()`(同 `untracked()`)。
|
|
7
|
+
- [Angular signals](https://angular.dev/guide/signals): 受该项目启发,Reactor 补充了一些额外能力,包括但不限于 `assertWithoutTracking()`(同 `assertNotInReactiveContext()`)、`options.isEqual()`(同 `options.equal()`)、`signal.setWithoutCalculate()`(同 `signal.update()`)、`derived()`(原语层面的 `linkedSignal()`)。
|
|
8
|
+
- [RxJS](https://github.com/ReactiveX/rxjs):Reactor 的 operators 参考了 RxJS 的 operators 列表与功能,但两者有着本质的区别,RxJS 的 operators 负责管理值的流动与转换,而 Reactor 的 operators 只是围绕 Reactor 原语提供的一些便捷工具函数,Reactor 的核心价值在于其响应式原语,而非 operators,operators 对于 RxJS 来说不可或缺,但 operators 对于 Reactor 来说并非必需。
|
|
9
|
+
|
|
10
|
+
Reactor operators 分为以下几类:
|
|
11
|
+
|
|
12
|
+
1. utility:实用工具函数。
|
|
13
|
+
2. convert:类型转换相关。
|
|
14
|
+
3. create:创建相关。
|
|
15
|
+
4. join:合并相关(多个 Reactor 组合为一个 Reactor)。
|
|
16
|
+
5. branch:分支相关(一个 Reactor 变为多个 Reactor)。
|
|
17
|
+
6. map:映射相关(一个 Reactor 变换为另一个 Reactor)。
|
|
18
|
+
7. filter:过滤相关(一个 Reactor 变换为另一个 Reactor,本质是特殊的 map)。
|