reactronic 0.94.25037 → 0.95.25040
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -66
- package/build/dist/source/Enums.d.ts +3 -3
- package/build/dist/source/Enums.js +3 -3
- package/build/dist/source/OperationEx.d.ts +2 -2
- package/build/dist/source/OperationEx.js +5 -5
- package/build/dist/source/Options.d.ts +2 -2
- package/build/dist/source/Pipe.d.ts +2 -2
- package/build/dist/source/Pipe.js +2 -2
- package/build/dist/source/Ref.d.ts +2 -2
- package/build/dist/source/Ref.js +5 -5
- package/build/dist/source/System.d.ts +14 -14
- package/build/dist/source/System.js +22 -22
- package/build/dist/source/api.d.ts +7 -7
- package/build/dist/source/api.js +6 -6
- package/build/dist/source/core/Changeset.js +1 -1
- package/build/dist/source/core/Data.d.ts +1 -1
- package/build/dist/source/core/Indicator.d.ts +2 -2
- package/build/dist/source/core/Indicator.js +2 -2
- package/build/dist/source/core/Journal.d.ts +2 -2
- package/build/dist/source/core/Journal.js +2 -2
- package/build/dist/source/core/Mvcc.d.ts +10 -10
- package/build/dist/source/core/Mvcc.js +19 -19
- package/build/dist/source/core/MvccArray.d.ts +3 -3
- package/build/dist/source/core/MvccArray.js +4 -4
- package/build/dist/source/core/MvccMap.d.ts +3 -3
- package/build/dist/source/core/MvccMap.js +4 -4
- package/build/dist/source/core/MvccReconciliationList.d.ts +12 -11
- package/build/dist/source/core/MvccReconciliationList.js +12 -11
- package/build/dist/source/core/Operation.d.ts +8 -8
- package/build/dist/source/core/Operation.js +41 -41
- package/build/dist/source/core/Transaction.js +28 -28
- package/build/dist/source/core/TreeNode.d.ts +17 -17
- package/build/dist/source/core/TreeNode.js +52 -52
- package/build/dist/source/util/LinkedList.d.ts +52 -0
- package/build/dist/source/util/LinkedList.js +177 -0
- package/build/dist/source/util/LinkedListRenovation.d.ts +20 -0
- package/build/dist/source/util/LinkedListRenovation.js +134 -0
- package/build/dist/source/util/ReconciliationList.d.ts +10 -8
- package/build/dist/source/util/ReconciliationList.js +59 -58
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -20,23 +20,23 @@ corresponding visual components for (re)rendering. All
|
|
|
20
20
|
that is done in automatic, seamless, and fine-grained
|
|
21
21
|
way. Reactronic **takes full care of tracking dependencies**
|
|
22
22
|
between visual components (reactive functions) and
|
|
23
|
-
application state (
|
|
23
|
+
application state (signalling objects).
|
|
24
24
|
|
|
25
25
|
Transactional reactivity is based on four fundamental
|
|
26
26
|
concepts:
|
|
27
27
|
|
|
28
|
-
- **
|
|
28
|
+
- **Signalling Objects** - a set of objects that store
|
|
29
29
|
data of an application (state) and cause reactions
|
|
30
30
|
upon their changes;
|
|
31
|
-
- **
|
|
32
|
-
in
|
|
33
|
-
nothing");
|
|
34
|
-
- **
|
|
31
|
+
- **Transactional Function** - a function that makes
|
|
32
|
+
changes in signalling objects in atomic way ("all
|
|
33
|
+
or nothing");
|
|
34
|
+
- **Reactive Function** - a function that is
|
|
35
35
|
(re-)executed in response to changes made in
|
|
36
|
-
|
|
37
|
-
- **Cache** - a function which result is
|
|
38
|
-
and, if becomes obsolete, causes
|
|
39
|
-
re-execute on-demand.
|
|
36
|
+
signalling objects by transactional functions;
|
|
37
|
+
- **Cache Function** - a function which result is
|
|
38
|
+
remembered and, if becomes obsolete, causes
|
|
39
|
+
function to re-execute on-demand.
|
|
40
40
|
|
|
41
41
|
Demo application built with Reactronic: https://nevod.io/#/playground.
|
|
42
42
|
Source code of the demo: https://gitlab.com/nezaboodka/nevod.web.public/-/blob/master/README.md.
|
|
@@ -48,17 +48,17 @@ Quick introduction and detailed description is below.
|
|
|
48
48
|
Here is an example of transactional reactive code:
|
|
49
49
|
|
|
50
50
|
``` typescript
|
|
51
|
-
class Demo extends
|
|
51
|
+
class Demo extends SignallingObject {
|
|
52
52
|
name: string = 'Nezaboodka Software'
|
|
53
53
|
email: string = 'contact@nezaboodka.com'
|
|
54
54
|
|
|
55
|
-
@
|
|
55
|
+
@transaction
|
|
56
56
|
saveContact(name: string, email: string): void {
|
|
57
57
|
this.name = name
|
|
58
58
|
this.email = email
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
@
|
|
61
|
+
@reaction
|
|
62
62
|
printContact(): void {
|
|
63
63
|
// depends on `name` and `email` and reacts to their changes
|
|
64
64
|
if (this.email.indexOf('@') >= 0)
|
|
@@ -68,28 +68,28 @@ class Demo extends ObservableObject {
|
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
In the example above, `Demo` is
|
|
71
|
+
In the example above, `Demo` is a signalling object,
|
|
72
72
|
meaning that access to its fields are seamlessly tracked
|
|
73
73
|
to determine dependent reactive and cached functions.
|
|
74
74
|
Reactive function `printContact` reads `name` and `email`
|
|
75
75
|
fields, thus depends on them. It is executed automatically
|
|
76
|
-
in response to changes of these fields made by the
|
|
77
|
-
function `saveContact`.
|
|
76
|
+
in response to changes of these fields made by the
|
|
77
|
+
transactional function `saveContact`.
|
|
78
78
|
|
|
79
79
|
Here is an example of a cached result that is
|
|
80
80
|
(re-)computed on-demand:
|
|
81
81
|
|
|
82
82
|
``` typescript
|
|
83
|
-
class Demo extends
|
|
83
|
+
class Demo extends SignallingObject {
|
|
84
84
|
name: string = 'Nezaboodka Software'
|
|
85
85
|
email: string = 'contact@nezaboodka.com'
|
|
86
86
|
|
|
87
|
-
@
|
|
87
|
+
@cache
|
|
88
88
|
get contact(): string {
|
|
89
89
|
return this.name + ' <' + this.email + '>'
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
@
|
|
92
|
+
@reaction
|
|
93
93
|
printContact(): void {
|
|
94
94
|
if (this.contact !== '')
|
|
95
95
|
Console.log(this.contact)
|
|
@@ -107,15 +107,15 @@ thus causing execution of depending reactive function
|
|
|
107
107
|
`printContact` runs it reads `contact` and causes its
|
|
108
108
|
re-computation.
|
|
109
109
|
|
|
110
|
-
##
|
|
110
|
+
## Signalling Objects
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
Signalling objects are aimed to store data of
|
|
113
113
|
an application. All such objects are transparently hooked
|
|
114
114
|
to track access to their properties, both on reads and
|
|
115
115
|
writes.
|
|
116
116
|
|
|
117
117
|
``` typescript
|
|
118
|
-
class MyModel extends
|
|
118
|
+
class MyModel extends SignallingObject {
|
|
119
119
|
url: string = "https://github.com/nezaboodka/reactronic"
|
|
120
120
|
content: string = "transactional reactive state management"
|
|
121
121
|
timestamp: Date = Date.now()
|
|
@@ -123,21 +123,22 @@ class MyModel extends ObservableObject {
|
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
In the example above, the class `MyModel` is based on
|
|
126
|
-
Reactronic's `
|
|
126
|
+
Reactronic's `SignallingObject` class and all its
|
|
127
127
|
properties `url`, `content`, and `timestamp` are hooked.
|
|
128
128
|
|
|
129
|
-
##
|
|
129
|
+
## Transactional Function
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
in atomic (
|
|
133
|
-
of dependent reactive and cached functions.
|
|
134
|
-
function is instrumented with hooks to
|
|
135
|
-
(by implicit context
|
|
131
|
+
Transactional function makes changes in signalling
|
|
132
|
+
objects in atomic way ("all or nothing"), thus provoking
|
|
133
|
+
execution of dependent reactive and cached functions.
|
|
134
|
+
Transactional function is instrumented with hooks to
|
|
135
|
+
provide transparent atomicity (by implicit context
|
|
136
|
+
switching and isolation).
|
|
136
137
|
|
|
137
138
|
``` typescript
|
|
138
|
-
class MyModel extends
|
|
139
|
+
class MyModel extends SignallingObject {
|
|
139
140
|
// ...
|
|
140
|
-
@
|
|
141
|
+
@transaction
|
|
141
142
|
async load(url: string): Promise<void> {
|
|
142
143
|
this.url = url
|
|
143
144
|
this.content = await fetch(url)
|
|
@@ -146,9 +147,9 @@ class MyModel extends ObservableObject {
|
|
|
146
147
|
}
|
|
147
148
|
```
|
|
148
149
|
|
|
149
|
-
In the example above, the
|
|
150
|
+
In the example above, the transactional function `load` makes
|
|
150
151
|
changes to `url`, `content` and `timestamp` properties.
|
|
151
|
-
While
|
|
152
|
+
While transactional function is running, the changes are visible
|
|
152
153
|
only inside the function itself. The new values become
|
|
153
154
|
atomically visible outside of the function only upon its
|
|
154
155
|
completion.
|
|
@@ -159,41 +160,41 @@ function until it is fully finished and applied. Multiple
|
|
|
159
160
|
objects and their properties can be changed with full
|
|
160
161
|
respect to the all-or-nothing principle. To do so,
|
|
161
162
|
separate data snapshot is automatically maintained for
|
|
162
|
-
each
|
|
163
|
-
not create a full copy of all the data.
|
|
163
|
+
each transactional function. That is a logical snapshot
|
|
164
|
+
that does not create a full copy of all the data.
|
|
164
165
|
|
|
165
166
|
Compensating rollback operations are not needed in case
|
|
166
|
-
of
|
|
167
|
-
made by
|
|
168
|
-
simply discarded. In case
|
|
167
|
+
of a transactional function failure, because all the changes
|
|
168
|
+
made by transactional function in its logical snapshot are
|
|
169
|
+
simply discarded. In case a transaction function is
|
|
169
170
|
successfully applied, affected cached results are marked
|
|
170
171
|
as obsolete and corresponding caching functions are
|
|
171
172
|
re-executed in a proper order (but only when all the
|
|
172
173
|
data changes are fully applied).
|
|
173
174
|
|
|
174
175
|
Asynchronous operations (promises) are supported out of
|
|
175
|
-
the box during
|
|
176
|
-
may consist of a set of asynchronous
|
|
177
|
-
the function until completion of all of
|
|
178
|
-
asynchronous call may spawn other asynchronous
|
|
179
|
-
which prolong
|
|
176
|
+
the box during transactional function execution.
|
|
177
|
+
Transactional function may consist of a set of asynchronous
|
|
178
|
+
calls prolonging the function until completion of all of
|
|
179
|
+
them. An asynchronous call may spawn other asynchronous
|
|
180
|
+
calls, which prolong transactional execution until the whole
|
|
180
181
|
chain of asynchronous operations is fully completed.
|
|
181
182
|
|
|
182
183
|
## Reactive & Cached Functions
|
|
183
184
|
|
|
184
185
|
Reactive function is automatically and immediately called
|
|
185
|
-
in response to changes in
|
|
186
|
-
|
|
187
|
-
renew the result if it was marked as obsolete due to
|
|
188
|
-
changes made by an
|
|
186
|
+
in response to changes in signalling objects made by
|
|
187
|
+
transactional functions. Cached function is called on-demand
|
|
188
|
+
to renew the result if it was marked as obsolete due to
|
|
189
|
+
changes made by an transactional functions. Reactive and cached
|
|
189
190
|
functions are instrumented with hooks to seamlessly
|
|
190
|
-
subscribe to those
|
|
191
|
+
subscribe to those signalling objects and other cached
|
|
191
192
|
functions (dependencies), which are used during their
|
|
192
193
|
execution.
|
|
193
194
|
|
|
194
195
|
``` tsx
|
|
195
196
|
class MyView extends Component<{model: MyModel}> {
|
|
196
|
-
@
|
|
197
|
+
@cache
|
|
197
198
|
render(): React.JSX.Element {
|
|
198
199
|
return (
|
|
199
200
|
<div>
|
|
@@ -207,12 +208,12 @@ class MyView extends Component<{model: MyModel}> {
|
|
|
207
208
|
|
|
208
209
|
``` tsx
|
|
209
210
|
class Component<P> extends React.Component<P> {
|
|
210
|
-
@
|
|
211
|
+
@cache
|
|
211
212
|
render(): React.JSX.Element {
|
|
212
213
|
throw new Error('render method is undefined')
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
@
|
|
216
|
+
@reaction // called in response to changes
|
|
216
217
|
ensureUpToDate(): void {
|
|
217
218
|
if (this.shouldComponentUpdate()) {
|
|
218
219
|
// Ask React to re-render
|
|
@@ -231,7 +232,7 @@ class Component<P> extends React.Component<P> {
|
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
componentWillUnmount(): void {
|
|
234
|
-
|
|
235
|
+
runTransactional(disposeSignallingObject, this)
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
```
|
|
@@ -250,14 +251,14 @@ cached value.
|
|
|
250
251
|
|
|
251
252
|
In general case, all reactive and cached functions
|
|
252
253
|
are automatically and immediately marked as obsolete
|
|
253
|
-
when changes are made in those
|
|
254
|
+
when changes are made in those signalling objects and
|
|
254
255
|
other cached results that were used during their
|
|
255
256
|
execution. And once marked, the functions are
|
|
256
257
|
automatically executed again, either immediately (for
|
|
257
258
|
reactive functions) or on-demand (for cached functions).
|
|
258
259
|
|
|
259
260
|
Reactronic takes full care of tracking dependencies
|
|
260
|
-
between all the
|
|
261
|
+
between all the signalling objects and reactive/cached
|
|
261
262
|
functions. With Reactronic, you no longer need to create
|
|
262
263
|
data change events in one set of objects, subscribe to
|
|
263
264
|
these events in other objects, and manually maintain
|
|
@@ -277,11 +278,11 @@ reactive functions:
|
|
|
277
278
|
is executed in case of recurring changes:
|
|
278
279
|
|
|
279
280
|
- `(ms)` - minimal delay in milliseconds between executions;
|
|
280
|
-
- `-1` - execute immediately once
|
|
281
|
+
- `-1` - execute immediately once transactional function changes are applied (synchronously);
|
|
281
282
|
- `0` - execute immediately via event loop (asynchronously with zero timeout);
|
|
282
283
|
- `>= Number.MAX_SAFE_INTEGER` - never execute (suspended reaction).
|
|
283
284
|
|
|
284
|
-
**Reentrance** option defines how to handle reentrant calls of
|
|
285
|
+
**Reentrance** option defines how to handle reentrant calls of transactional
|
|
285
286
|
and reactive functions:
|
|
286
287
|
|
|
287
288
|
- `preventWithError` - fail with error if there is an existing call in progress;
|
|
@@ -292,7 +293,7 @@ and reactive functions:
|
|
|
292
293
|
|
|
293
294
|
**Indicator** is an object that maintains status of running functions,
|
|
294
295
|
which it is attached to. A single indicator object can be shared between
|
|
295
|
-
multiple
|
|
296
|
+
multiple transactional, reactive, and cached functions, thus maintaining
|
|
296
297
|
consolidated status for all of them (busy, workers, etc).
|
|
297
298
|
|
|
298
299
|
## Notes
|
|
@@ -323,20 +324,20 @@ NPM: `npm install reactronic`
|
|
|
323
324
|
|
|
324
325
|
// Classes
|
|
325
326
|
|
|
326
|
-
class
|
|
327
|
-
class
|
|
327
|
+
class TransactionalObject { }
|
|
328
|
+
class SignallingObject { }
|
|
328
329
|
|
|
329
330
|
// Decorators & Operators
|
|
330
331
|
|
|
331
|
-
function
|
|
332
|
-
function
|
|
333
|
-
function
|
|
332
|
+
function signal(boolean) // field only
|
|
333
|
+
function signal(proto, prop) // field only
|
|
334
|
+
function transaction(proto, prop, pd) // method only
|
|
334
335
|
function reaction(proto, prop, pd) // method only
|
|
335
336
|
function cache(proto, prop, pd) // method only
|
|
336
337
|
function options(value: Partial<ReactivityOptions>): F<any>
|
|
337
338
|
|
|
338
|
-
function
|
|
339
|
-
function
|
|
339
|
+
function runNonReactive<T>(func: F<T>, ...args: any[]): T
|
|
340
|
+
function runSensitive<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
340
341
|
|
|
341
342
|
// SnapshotOptions, ReactivityOptions, Kind, Reentrance, Indicator, LoggingOptions, ProfilingOptions
|
|
342
343
|
|
|
@@ -353,7 +354,7 @@ type ReactivityOptions = {
|
|
|
353
354
|
readonly isolation: Isolation
|
|
354
355
|
readonly order: number
|
|
355
356
|
readonly noSideEffects: boolean
|
|
356
|
-
readonly
|
|
357
|
+
readonly signalArgs: boolean
|
|
357
358
|
readonly throttling: number // milliseconds, -1 is immediately, Number.MAX_SAFE_INTEGER is never
|
|
358
359
|
readonly reentrance: Reentrance
|
|
359
360
|
readonly journal: Journal | undefined
|
|
@@ -363,7 +364,7 @@ type ReactivityOptions = {
|
|
|
363
364
|
|
|
364
365
|
enum Kind {
|
|
365
366
|
plain = 0,
|
|
366
|
-
|
|
367
|
+
transaction = 1,
|
|
367
368
|
reaction = 2,
|
|
368
369
|
cache = 3
|
|
369
370
|
}
|
|
@@ -13,9 +13,9 @@ export var Priority;
|
|
|
13
13
|
export var Kind;
|
|
14
14
|
(function (Kind) {
|
|
15
15
|
Kind[Kind["plain"] = 0] = "plain";
|
|
16
|
-
Kind[Kind["
|
|
17
|
-
Kind[Kind["
|
|
18
|
-
Kind[Kind["
|
|
16
|
+
Kind[Kind["transaction"] = 1] = "transaction";
|
|
17
|
+
Kind[Kind["reaction"] = 2] = "reaction";
|
|
18
|
+
Kind[Kind["cache"] = 3] = "cache";
|
|
19
19
|
})(Kind || (Kind = {}));
|
|
20
20
|
export var Reentrance;
|
|
21
21
|
(function (Reentrance) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { F } from "./util/Utils.js";
|
|
2
|
-
import {
|
|
3
|
-
export declare class
|
|
2
|
+
import { SxObject } from "./core/Mvcc.js";
|
|
3
|
+
export declare class ReactionEx<T> extends SxObject {
|
|
4
4
|
protected operation: F<T>;
|
|
5
5
|
constructor(operation: F<T>);
|
|
6
6
|
protected launch(): T;
|
|
@@ -7,9 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
export class
|
|
10
|
+
import { SxObject } from "./core/Mvcc.js";
|
|
11
|
+
import { reaction } from "./System.js";
|
|
12
|
+
export class ReactionEx extends SxObject {
|
|
13
13
|
constructor(operation) {
|
|
14
14
|
super();
|
|
15
15
|
this.operation = operation;
|
|
@@ -19,8 +19,8 @@ export class ReactiveOperationEx extends ObservableObject {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
__decorate([
|
|
22
|
-
|
|
22
|
+
reaction,
|
|
23
23
|
__metadata("design:type", Function),
|
|
24
24
|
__metadata("design:paramtypes", []),
|
|
25
25
|
__metadata("design:returntype", Object)
|
|
26
|
-
],
|
|
26
|
+
], ReactionEx.prototype, "launch", null);
|
|
@@ -16,7 +16,7 @@ export type ReactivityOptions = {
|
|
|
16
16
|
readonly isolation: Isolation;
|
|
17
17
|
readonly order: number;
|
|
18
18
|
readonly noSideEffects: boolean;
|
|
19
|
-
readonly
|
|
19
|
+
readonly signalArgs: boolean;
|
|
20
20
|
readonly throttling: number;
|
|
21
21
|
readonly reentrance: Reentrance;
|
|
22
22
|
readonly allowObsoleteToFinish: boolean;
|
|
@@ -24,7 +24,7 @@ export type ReactivityOptions = {
|
|
|
24
24
|
readonly indicator: Indicator | null;
|
|
25
25
|
readonly logging?: Partial<LoggingOptions>;
|
|
26
26
|
};
|
|
27
|
-
export type
|
|
27
|
+
export type Reaction<T> = {
|
|
28
28
|
readonly options: ReactivityOptions;
|
|
29
29
|
readonly args: ReadonlyArray<any>;
|
|
30
30
|
readonly result: T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare abstract class Pipe<T> extends
|
|
1
|
+
import { SxObject } from "./core/Mvcc.js";
|
|
2
|
+
export declare abstract class Pipe<T> extends SxObject {
|
|
3
3
|
abstract readonly capacity: number;
|
|
4
4
|
abstract readonly count: number;
|
|
5
5
|
abstract put(...items: T[]): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { misuse } from "./util/Dbg.js";
|
|
2
|
-
import {
|
|
3
|
-
export class Pipe extends
|
|
2
|
+
import { SxObject } from "./core/Mvcc.js";
|
|
3
|
+
export class Pipe extends SxObject {
|
|
4
4
|
static create(hint, capacity) { throw misuse("not implemented"); }
|
|
5
5
|
}
|
|
@@ -28,8 +28,8 @@ export declare class Ref<T = any> {
|
|
|
28
28
|
get variable(): T;
|
|
29
29
|
set variable(value: T);
|
|
30
30
|
nonReactively(): T;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
signalling(): T;
|
|
32
|
+
nonSignalling(): T;
|
|
33
33
|
static sameRefs(v1: Ref, v2: Ref): boolean;
|
|
34
34
|
static similarRefs(v1: Ref, v2: Ref): boolean;
|
|
35
35
|
}
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { misuse } from "./util/Dbg.js";
|
|
2
|
-
import {
|
|
2
|
+
import { runTransactional, runNonReactive } from "./System.js";
|
|
3
3
|
export function refs(owner) {
|
|
4
4
|
return new Proxy(owner, RefGettingProxy);
|
|
5
5
|
}
|
|
@@ -29,12 +29,12 @@ export class Ref {
|
|
|
29
29
|
this.owner[this.name][this.index] = value;
|
|
30
30
|
}
|
|
31
31
|
nonReactively() {
|
|
32
|
-
return
|
|
32
|
+
return runNonReactive(() => this.variable);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
signalling() {
|
|
35
35
|
return this.variable;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
nonSignalling() {
|
|
38
38
|
throw misuse("not implemented");
|
|
39
39
|
}
|
|
40
40
|
static sameRefs(v1, v2) {
|
|
@@ -53,7 +53,7 @@ export class ToggleRef extends Ref {
|
|
|
53
53
|
toggle() {
|
|
54
54
|
const o = this.owner;
|
|
55
55
|
const p = this.name;
|
|
56
|
-
|
|
56
|
+
runTransactional({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
|
|
57
57
|
const v = o[p];
|
|
58
58
|
const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
|
|
59
59
|
Ref.sameRefs(v, this.valueOn));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { F } from "./util/Utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Reaction, ReactivityOptions, LoggingOptions, ProfilingOptions, SnapshotOptions } from "./Options.js";
|
|
3
3
|
export declare class ReactiveSystem {
|
|
4
4
|
static why(brief?: boolean): string;
|
|
5
5
|
static getRevisionOf(obj: any): number;
|
|
@@ -13,17 +13,17 @@ export declare class ReactiveSystem {
|
|
|
13
13
|
static getLoggingHint<T extends object>(obj: T, full?: boolean): string | undefined;
|
|
14
14
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
15
15
|
}
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
16
|
+
export declare function runTransactional<T>(func: F<T>, ...args: any[]): T;
|
|
17
|
+
export declare function runTransactional<T>(options: SnapshotOptions, func: F<T>, ...args: any[]): T;
|
|
18
|
+
export declare function runNonReactive<T>(func: F<T>, ...args: any[]): T;
|
|
19
|
+
export declare function runSensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
20
|
+
export declare function runContextual<T>(p: Promise<T>): Promise<T>;
|
|
21
|
+
export declare function manageReaction<T>(method: F<T>): Reaction<T>;
|
|
22
|
+
export declare function configureCurrentReaction(options: Partial<ReactivityOptions>): ReactivityOptions;
|
|
23
|
+
export declare function disposeSignallingObject(obj: any): void;
|
|
24
|
+
export declare function signal(enabled: boolean): (proto: object, prop: PropertyKey) => any;
|
|
25
|
+
export declare function signal<T>(proto: object, prop: PropertyKey): any;
|
|
26
|
+
export declare function transaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
27
|
+
export declare function reaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
28
|
+
export declare function cache(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
29
29
|
export declare function options(value: Partial<ReactivityOptions>): F<any>;
|
|
@@ -4,9 +4,9 @@ import { Meta, ObjectHandle } from "./core/Data.js";
|
|
|
4
4
|
import { Changeset } from "./core/Changeset.js";
|
|
5
5
|
import { Mvcc } from "./core/Mvcc.js";
|
|
6
6
|
import { Transaction } from "./core/Transaction.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ReactionImpl } from "./core/Operation.js";
|
|
8
8
|
export class ReactiveSystem {
|
|
9
|
-
static why(brief = false) { return brief ?
|
|
9
|
+
static why(brief = false) { return brief ? ReactionImpl.briefWhy() : ReactionImpl.why(); }
|
|
10
10
|
static getRevisionOf(obj) { return obj[Meta.Revision]; }
|
|
11
11
|
static takeSnapshot(obj) { return Changeset.takeSnapshot(obj); }
|
|
12
12
|
static get reactivityAutoStartDisabled() { return Mvcc.reactivityAutoStartDisabled; }
|
|
@@ -18,7 +18,7 @@ export class ReactiveSystem {
|
|
|
18
18
|
static getLoggingHint(obj, full = false) { return ObjectHandle.getHint(obj, full); }
|
|
19
19
|
static setProfilingMode(isOn, options) { Mvcc.setProfilingMode(isOn, options); }
|
|
20
20
|
}
|
|
21
|
-
export function
|
|
21
|
+
export function runTransactional(p1, p2, p3) {
|
|
22
22
|
if (p1 instanceof Function) {
|
|
23
23
|
if (p2 !== undefined)
|
|
24
24
|
return Transaction.run(null, p1, ...p2);
|
|
@@ -32,25 +32,25 @@ export function runAtomically(p1, p2, p3) {
|
|
|
32
32
|
return Transaction.run(p1, p2);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
export function
|
|
36
|
-
return
|
|
35
|
+
export function runNonReactive(func, ...args) {
|
|
36
|
+
return ReactionImpl.proceedWithinGivenLaunch(undefined, func, ...args);
|
|
37
37
|
}
|
|
38
|
-
export function
|
|
38
|
+
export function runSensitive(sensitivity, func, ...args) {
|
|
39
39
|
return Mvcc.sensitive(sensitivity, func, ...args);
|
|
40
40
|
}
|
|
41
|
-
export function
|
|
41
|
+
export function runContextual(p) {
|
|
42
42
|
throw misuse("not implemented yet");
|
|
43
43
|
}
|
|
44
|
-
export function
|
|
45
|
-
return
|
|
44
|
+
export function manageReaction(method) {
|
|
45
|
+
return ReactionImpl.manageReaction(method);
|
|
46
46
|
}
|
|
47
|
-
export function
|
|
48
|
-
return
|
|
47
|
+
export function configureCurrentReaction(options) {
|
|
48
|
+
return ReactionImpl.configureImpl(undefined, options);
|
|
49
49
|
}
|
|
50
|
-
export function
|
|
50
|
+
export function disposeSignallingObject(obj) {
|
|
51
51
|
Changeset.dispose(obj);
|
|
52
52
|
}
|
|
53
|
-
export function
|
|
53
|
+
export function signal(protoOrEnabled, prop) {
|
|
54
54
|
if (typeof (protoOrEnabled) === "boolean") {
|
|
55
55
|
return (proto, prop) => {
|
|
56
56
|
return Mvcc.decorateData(protoOrEnabled, proto, prop);
|
|
@@ -59,28 +59,28 @@ export function observable(protoOrEnabled, prop) {
|
|
|
59
59
|
else
|
|
60
60
|
return Mvcc.decorateData(true, protoOrEnabled, prop);
|
|
61
61
|
}
|
|
62
|
-
export function
|
|
62
|
+
export function transaction(proto, prop, pd) {
|
|
63
63
|
const opts = {
|
|
64
|
-
kind: Kind.
|
|
64
|
+
kind: Kind.transaction,
|
|
65
65
|
isolation: Isolation.joinToCurrentTransaction,
|
|
66
66
|
};
|
|
67
|
-
return Mvcc.decorateOperation(true,
|
|
67
|
+
return Mvcc.decorateOperation(true, transaction, opts, proto, prop, pd);
|
|
68
68
|
}
|
|
69
|
-
export function
|
|
69
|
+
export function reaction(proto, prop, pd) {
|
|
70
70
|
const opts = {
|
|
71
|
-
kind: Kind.
|
|
71
|
+
kind: Kind.reaction,
|
|
72
72
|
isolation: Isolation.joinAsNestedTransaction,
|
|
73
73
|
throttling: -1,
|
|
74
74
|
};
|
|
75
|
-
return Mvcc.decorateOperation(true,
|
|
75
|
+
return Mvcc.decorateOperation(true, reaction, opts, proto, prop, pd);
|
|
76
76
|
}
|
|
77
|
-
export function
|
|
77
|
+
export function cache(proto, prop, pd) {
|
|
78
78
|
const opts = {
|
|
79
|
-
kind: Kind.
|
|
79
|
+
kind: Kind.cache,
|
|
80
80
|
isolation: Isolation.joinToCurrentTransaction,
|
|
81
81
|
noSideEffects: true,
|
|
82
82
|
};
|
|
83
|
-
return Mvcc.decorateOperation(true,
|
|
83
|
+
return Mvcc.decorateOperation(true, cache, opts, proto, prop, pd);
|
|
84
84
|
}
|
|
85
85
|
export function options(value) {
|
|
86
86
|
return Mvcc.decorateOperationParametrized(options, value);
|
|
@@ -7,19 +7,19 @@ export { SealedMap } from "./util/SealedMap.js";
|
|
|
7
7
|
export { SealedSet } from "./util/SealedSet.js";
|
|
8
8
|
export { LoggingLevel } from "./Options.js";
|
|
9
9
|
export { Mode, Priority, Kind, Reentrance, Isolation } from "./Enums.js";
|
|
10
|
-
export type {
|
|
10
|
+
export type { Reaction, ReactivityOptions, SnapshotOptions, LoggingOptions, ProfilingOptions } from "./Options.js";
|
|
11
11
|
export type { Worker } from "./Worker.js";
|
|
12
12
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from "./Ref.js";
|
|
13
13
|
export type { BoolOnly, GivenTypeOnly } from "./Ref.js";
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
14
|
+
export { TxObject, SxObject } from "./core/Mvcc.js";
|
|
15
|
+
export { TxArray, SxArray } from "./core/MvccArray.js";
|
|
16
|
+
export { TxMap, SxMap } from "./core/MvccMap.js";
|
|
17
17
|
export { Changeset } from "./core/Changeset.js";
|
|
18
18
|
export { Transaction } from "./core/Transaction.js";
|
|
19
19
|
export { Indicator } from "./core/Indicator.js";
|
|
20
20
|
export { Journal } from "./core/Journal.js";
|
|
21
|
-
export {
|
|
22
|
-
export { ReactiveSystem,
|
|
23
|
-
export {
|
|
21
|
+
export { runTransactional, runNonReactive, runSensitive, runContextual, manageReaction, configureCurrentReaction, disposeSignallingObject } from "./System.js";
|
|
22
|
+
export { ReactiveSystem, signal, transaction, reaction, cache, options } from "./System.js";
|
|
23
|
+
export { ReactionEx } from "./OperationEx.js";
|
|
24
24
|
export { declare, derivative, launch, ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|
|
25
25
|
export type { Script, ScriptAsync, Handler, ReactiveTreeNodeDecl, ReactiveTreeNodeDriver, ReactiveTreeNodeContext } from "./core/TreeNode.js";
|
package/build/dist/source/api.js
CHANGED
|
@@ -7,14 +7,14 @@ export { SealedSet } from "./util/SealedSet.js";
|
|
|
7
7
|
export { LoggingLevel } from "./Options.js";
|
|
8
8
|
export { Mode, Priority, Kind, Reentrance, Isolation } from "./Enums.js";
|
|
9
9
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from "./Ref.js";
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
10
|
+
export { TxObject, SxObject } from "./core/Mvcc.js";
|
|
11
|
+
export { TxArray, SxArray } from "./core/MvccArray.js";
|
|
12
|
+
export { TxMap, SxMap } from "./core/MvccMap.js";
|
|
13
13
|
export { Changeset } from "./core/Changeset.js";
|
|
14
14
|
export { Transaction } from "./core/Transaction.js";
|
|
15
15
|
export { Indicator } from "./core/Indicator.js";
|
|
16
16
|
export { Journal } from "./core/Journal.js";
|
|
17
|
-
export {
|
|
18
|
-
export { ReactiveSystem,
|
|
19
|
-
export {
|
|
17
|
+
export { runTransactional, runNonReactive, runSensitive, runContextual, manageReaction, configureCurrentReaction, disposeSignallingObject } from "./System.js";
|
|
18
|
+
export { ReactiveSystem, signal, transaction, reaction, cache, options } from "./System.js";
|
|
19
|
+
export { ReactionEx } from "./OperationEx.js";
|
|
20
20
|
export { declare, derivative, launch, ReactiveTreeNode, BaseDriver, ReactiveTreeVariable } from "./core/TreeNode.js";
|