reactronic 0.22.300 → 0.22.301
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 +20 -20
- package/build/dist/source/Buffer.d.ts +2 -2
- package/build/dist/source/Buffer.js +1 -1
- package/build/dist/source/Ref.d.ts +1 -1
- package/build/dist/source/Ref.js +2 -2
- package/build/dist/source/Rx.d.ts +2 -2
- package/build/dist/source/Rx.js +5 -5
- package/build/dist/source/api.d.ts +2 -2
- package/build/dist/source/api.js +4 -4
- package/build/dist/source/impl/Hooks.d.ts +3 -3
- package/build/dist/source/impl/Hooks.js +8 -8
- package/build/dist/source/impl/Journal.d.ts +2 -2
- package/build/dist/source/impl/Journal.js +1 -1
- package/build/dist/source/impl/Meta.d.ts +1 -1
- package/build/dist/source/impl/Meta.js +1 -1
- package/build/dist/source/impl/Monitor.d.ts +2 -2
- package/build/dist/source/impl/Monitor.js +1 -1
- package/build/dist/source/impl/Operation.d.ts +1 -1
- package/build/dist/source/impl/Operation.js +1 -1
- package/build/dist/source/impl/Snapshot.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,13 +19,13 @@ isolated data snapshot and then, once atomically applied, are
|
|
|
19
19
|
**consistently propagated** to corresponding visual components for
|
|
20
20
|
(re)rendering. All that is done in automatic, seamless, and fine-grained
|
|
21
21
|
way, because reactronic **takes full care of tracking dependencies**
|
|
22
|
-
between visual components (subscribers) and state (
|
|
22
|
+
between visual components (subscribers) and state (reactive objects).
|
|
23
23
|
|
|
24
24
|
Transactional reactivity is based on four fundamental concepts:
|
|
25
25
|
|
|
26
|
-
- **
|
|
26
|
+
- **Reactive Objects** - a set of objects that store data of an
|
|
27
27
|
application (state) and maintain subscription lists;
|
|
28
|
-
- **Transaction** - a function that makes changes in
|
|
28
|
+
- **Transaction** - a function that makes changes in reactive
|
|
29
29
|
objects in transactional (atomic) way;
|
|
30
30
|
- **Reaction** - a function that is executed automatically in
|
|
31
31
|
response to changes made by a transaction;
|
|
@@ -40,10 +40,10 @@ Quick introduction and detailed description is below.
|
|
|
40
40
|
## Quick Introduction
|
|
41
41
|
|
|
42
42
|
Here is an example of transactional reactive code with
|
|
43
|
-
|
|
43
|
+
reactive object, transaction and reaction:
|
|
44
44
|
|
|
45
45
|
``` typescript
|
|
46
|
-
class Demo extends
|
|
46
|
+
class Demo extends ReactiveObject {
|
|
47
47
|
name: string = 'Nezaboodka Software'
|
|
48
48
|
email: string = 'contact@nezaboodka.com'
|
|
49
49
|
|
|
@@ -70,7 +70,7 @@ to changes of these fields made by `saveContact` transaction.
|
|
|
70
70
|
Here is an example of if cached value computed on-demand:
|
|
71
71
|
|
|
72
72
|
``` typescript
|
|
73
|
-
class Demo extends
|
|
73
|
+
class Demo extends ReactiveObject {
|
|
74
74
|
name: string = 'Nezaboodka Software'
|
|
75
75
|
email: string = 'contact@nezaboodka.com'
|
|
76
76
|
|
|
@@ -95,14 +95,14 @@ invalidated, thus causing execution of depending reaction
|
|
|
95
95
|
`printContact`. Then `printContact` reaction causes `contact`
|
|
96
96
|
re-computation on the first use.
|
|
97
97
|
|
|
98
|
-
##
|
|
98
|
+
## Reactive Objects
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
Reactive objects store data of an application. All such objects
|
|
101
101
|
are transparently hooked to track access to their properties,
|
|
102
102
|
both on reads and writes.
|
|
103
103
|
|
|
104
104
|
``` typescript
|
|
105
|
-
class MyModel extends
|
|
105
|
+
class MyModel extends ReactiveObject {
|
|
106
106
|
url: string = "https://github.com/nezaboodka/reactronic"
|
|
107
107
|
content: string = "transactional reactive state management"
|
|
108
108
|
timestamp: Date = Date.now()
|
|
@@ -110,18 +110,18 @@ class MyModel extends SubscribingObject {
|
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
In the example above, the class `MyModel` is based on Reactronic's
|
|
113
|
-
`
|
|
113
|
+
`ReactiveObject` class and all its properties `url`, `content`,
|
|
114
114
|
and `timestamp` are hooked.
|
|
115
115
|
|
|
116
116
|
## Transaction
|
|
117
117
|
|
|
118
|
-
Transaction is a function that makes changes in
|
|
118
|
+
Transaction is a function that makes changes in reactive objects
|
|
119
119
|
in transactional (atomic) way. Such a function is instrumented with hooks
|
|
120
120
|
to provide transparent atomicity (by implicit context switching
|
|
121
121
|
and isolation).
|
|
122
122
|
|
|
123
123
|
``` typescript
|
|
124
|
-
class MyModel extends
|
|
124
|
+
class MyModel extends ReactiveObject {
|
|
125
125
|
// ...
|
|
126
126
|
@transaction
|
|
127
127
|
async load(url: string): Promise<void> {
|
|
@@ -164,12 +164,12 @@ of asynchronous operations is fully completed.
|
|
|
164
164
|
## Reaction & Cache
|
|
165
165
|
|
|
166
166
|
Reaction is an code block that is immediately called in response to
|
|
167
|
-
changes made by a transaction in
|
|
167
|
+
changes made by a transaction in reactive objects. Cache is a
|
|
168
168
|
computed value having an associated function that is called
|
|
169
169
|
on-demand to renew the value if it was marked as obsolete due to changes
|
|
170
170
|
made by a transaction. Reactive and cached functions are
|
|
171
171
|
instrumented with hooks to seamlessly subscribe to those
|
|
172
|
-
|
|
172
|
+
reactive objects and other cached functions (dependencies),
|
|
173
173
|
which are used during their execution.
|
|
174
174
|
|
|
175
175
|
``` tsx
|
|
@@ -223,15 +223,15 @@ function enqueues re-rendering request to React, which calls
|
|
|
223
223
|
`render` function causing it to renew its cached value.
|
|
224
224
|
|
|
225
225
|
In general case, all reactions and caches are automatically and
|
|
226
|
-
immediately marked as obsolete when changes are made in those
|
|
226
|
+
immediately marked as obsolete when changes are made in those reactive
|
|
227
227
|
objects and cached functions that were used during their execution.
|
|
228
228
|
And once marked, the functions are automatically executed again,
|
|
229
229
|
either immediately (for @reactive functions) or on-demand
|
|
230
230
|
(for @cached functions).
|
|
231
231
|
|
|
232
232
|
Reactronic takes full care of tracking dependencies between
|
|
233
|
-
all the
|
|
234
|
-
|
|
233
|
+
all the reactive objects and reactions/caches.
|
|
234
|
+
With Reactronic, you no longer need to create data change events
|
|
235
235
|
in one set of objects, subscribe to these events in other objects,
|
|
236
236
|
and manually maintain switching from the previous object version
|
|
237
237
|
to a new one.
|
|
@@ -292,17 +292,17 @@ NPM: `npm install reactronic`
|
|
|
292
292
|
|
|
293
293
|
// Classes
|
|
294
294
|
|
|
295
|
-
class
|
|
295
|
+
class ReactiveObject { }
|
|
296
296
|
|
|
297
297
|
// Decorators & Operators
|
|
298
298
|
|
|
299
|
-
function
|
|
299
|
+
function plain(proto, prop) // field only
|
|
300
300
|
function transaction(proto, prop, pd) // method only
|
|
301
301
|
function reaction(proto, prop, pd) // method only
|
|
302
302
|
function cached(proto, prop, pd) // method only
|
|
303
303
|
function options(value: Partial<MemberOptions>): F<any>
|
|
304
304
|
|
|
305
|
-
function
|
|
305
|
+
function nonreactive<T>(func: F<T>, ...args: any[]): T
|
|
306
306
|
function sensitive<T>(sensitivity: Sensitivity, func: F<T>, ...args: any[]): T
|
|
307
307
|
|
|
308
308
|
// SnapshotOptions, MemberOptions, Kind, Reentrance, Monitor, LoggingOptions, ProfilingOptions
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare abstract class Buffer<T> extends
|
|
1
|
+
import { ReactiveObject } from './impl/Hooks';
|
|
2
|
+
export declare abstract class Buffer<T> extends ReactiveObject {
|
|
3
3
|
abstract readonly capacity: number;
|
|
4
4
|
abstract readonly count: number;
|
|
5
5
|
abstract put(...items: T[]): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Buffer = void 0;
|
|
4
4
|
const Hooks_1 = require("./impl/Hooks");
|
|
5
|
-
class Buffer extends Hooks_1.
|
|
5
|
+
class Buffer extends Hooks_1.ReactiveObject {
|
|
6
6
|
static create(hint, capacity) { throw new Error('not implemented'); }
|
|
7
7
|
}
|
|
8
8
|
exports.Buffer = Buffer;
|
|
@@ -11,7 +11,7 @@ export declare class Ref<T = any> {
|
|
|
11
11
|
constructor(owner: any, name: string, index?: number);
|
|
12
12
|
get value(): T;
|
|
13
13
|
set value(value: T);
|
|
14
|
-
|
|
14
|
+
nonreactive(): T;
|
|
15
15
|
observe(): T;
|
|
16
16
|
unobserve(): T;
|
|
17
17
|
static to<O extends object = object>(owner: O): {
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -21,8 +21,8 @@ class Ref {
|
|
|
21
21
|
else
|
|
22
22
|
this.owner[this.name][this.index] = value;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
return (0, Rx_1.
|
|
24
|
+
nonreactive() {
|
|
25
|
+
return (0, Rx_1.nonreactive)(() => this.value);
|
|
26
26
|
}
|
|
27
27
|
observe() {
|
|
28
28
|
return this.value;
|
|
@@ -17,9 +17,9 @@ export declare class Rx {
|
|
|
17
17
|
static getLoggingHint<T extends object>(obj: T, full?: boolean): string | undefined;
|
|
18
18
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
19
19
|
}
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function nonreactive<T>(func: F<T>, ...args: any[]): T;
|
|
21
21
|
export declare function sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function plain(proto: object, prop: PropertyKey): any;
|
|
23
23
|
export declare function transaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
24
24
|
export declare function reaction(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
|
25
25
|
export declare function cached(proto: object, prop: PropertyKey, pd: PropertyDescriptor): any;
|
package/build/dist/source/Rx.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.options = exports.cached = exports.reaction = exports.transaction = exports.
|
|
3
|
+
exports.options = exports.cached = exports.reaction = exports.transaction = exports.plain = exports.sensitive = exports.nonreactive = exports.Rx = void 0;
|
|
4
4
|
const Dbg_1 = require("./util/Dbg");
|
|
5
5
|
const Options_1 = require("./Options");
|
|
6
6
|
const Data_1 = require("./impl/Data");
|
|
@@ -24,18 +24,18 @@ class Rx {
|
|
|
24
24
|
static setProfilingMode(isOn, options) { Hooks_1.Hooks.setProfilingMode(isOn, options); }
|
|
25
25
|
}
|
|
26
26
|
exports.Rx = Rx;
|
|
27
|
-
function
|
|
27
|
+
function nonreactive(func, ...args) {
|
|
28
28
|
return Operation_1.OperationController.runWithin(undefined, func, ...args);
|
|
29
29
|
}
|
|
30
|
-
exports.
|
|
30
|
+
exports.nonreactive = nonreactive;
|
|
31
31
|
function sensitive(sensitivity, func, ...args) {
|
|
32
32
|
return Hooks_1.Hooks.sensitive(sensitivity, func, ...args);
|
|
33
33
|
}
|
|
34
34
|
exports.sensitive = sensitive;
|
|
35
|
-
function
|
|
35
|
+
function plain(proto, prop) {
|
|
36
36
|
return Hooks_1.Hooks.decorateData(false, proto, prop);
|
|
37
37
|
}
|
|
38
|
-
exports.
|
|
38
|
+
exports.plain = plain;
|
|
39
39
|
function transaction(proto, prop, pd) {
|
|
40
40
|
const opts = { kind: Options_1.Kind.Transaction };
|
|
41
41
|
return Hooks_1.Hooks.decorateOperation(true, transaction, opts, proto, prop, pd);
|
|
@@ -6,9 +6,9 @@ export { MemberOptions, SnapshotOptions, Kind, Reentrance, LoggingOptions, Profi
|
|
|
6
6
|
export { Worker } from './Worker';
|
|
7
7
|
export { Controller } from './Controller';
|
|
8
8
|
export { Ref, ToggleRef, BoolOnly, GivenTypeOnly } from './Ref';
|
|
9
|
-
export {
|
|
9
|
+
export { ReactiveObject } from './impl/Hooks';
|
|
10
10
|
export { Snapshot } from './impl/Snapshot';
|
|
11
11
|
export { Transaction } from './impl/Transaction';
|
|
12
12
|
export { Monitor } from './impl/Monitor';
|
|
13
13
|
export { Journal } from './impl/Journal';
|
|
14
|
-
export { Rx,
|
|
14
|
+
export { Rx, nonreactive, sensitive, plain, transaction, reaction, cached, options } from './Rx';
|
package/build/dist/source/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.options = exports.cached = exports.reaction = exports.transaction = exports.
|
|
3
|
+
exports.options = exports.cached = exports.reaction = exports.transaction = exports.plain = exports.sensitive = exports.nonreactive = exports.Rx = exports.Journal = exports.Monitor = exports.Transaction = exports.Snapshot = exports.ReactiveObject = exports.ToggleRef = exports.Ref = exports.Controller = exports.LoggingLevel = exports.Reentrance = exports.Kind = exports.SealedSet = exports.SealedMap = exports.SealedArray = exports.pause = exports.all = void 0;
|
|
4
4
|
var Utils_1 = require("./util/Utils");
|
|
5
5
|
Object.defineProperty(exports, "all", { enumerable: true, get: function () { return Utils_1.all; } });
|
|
6
6
|
Object.defineProperty(exports, "pause", { enumerable: true, get: function () { return Utils_1.pause; } });
|
|
@@ -20,7 +20,7 @@ var Ref_1 = require("./Ref");
|
|
|
20
20
|
Object.defineProperty(exports, "Ref", { enumerable: true, get: function () { return Ref_1.Ref; } });
|
|
21
21
|
Object.defineProperty(exports, "ToggleRef", { enumerable: true, get: function () { return Ref_1.ToggleRef; } });
|
|
22
22
|
var Hooks_1 = require("./impl/Hooks");
|
|
23
|
-
Object.defineProperty(exports, "
|
|
23
|
+
Object.defineProperty(exports, "ReactiveObject", { enumerable: true, get: function () { return Hooks_1.ReactiveObject; } });
|
|
24
24
|
var Snapshot_1 = require("./impl/Snapshot");
|
|
25
25
|
Object.defineProperty(exports, "Snapshot", { enumerable: true, get: function () { return Snapshot_1.Snapshot; } });
|
|
26
26
|
var Transaction_1 = require("./impl/Transaction");
|
|
@@ -31,9 +31,9 @@ var Journal_1 = require("./impl/Journal");
|
|
|
31
31
|
Object.defineProperty(exports, "Journal", { enumerable: true, get: function () { return Journal_1.Journal; } });
|
|
32
32
|
var Rx_1 = require("./Rx");
|
|
33
33
|
Object.defineProperty(exports, "Rx", { enumerable: true, get: function () { return Rx_1.Rx; } });
|
|
34
|
-
Object.defineProperty(exports, "
|
|
34
|
+
Object.defineProperty(exports, "nonreactive", { enumerable: true, get: function () { return Rx_1.nonreactive; } });
|
|
35
35
|
Object.defineProperty(exports, "sensitive", { enumerable: true, get: function () { return Rx_1.sensitive; } });
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "plain", { enumerable: true, get: function () { return Rx_1.plain; } });
|
|
37
37
|
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return Rx_1.transaction; } });
|
|
38
38
|
Object.defineProperty(exports, "reaction", { enumerable: true, get: function () { return Rx_1.reaction; } });
|
|
39
39
|
Object.defineProperty(exports, "cached", { enumerable: true, get: function () { return Rx_1.cached; } });
|
|
@@ -4,7 +4,7 @@ import { LoggingOptions, ProfilingOptions } from '../Logging';
|
|
|
4
4
|
import { MemberName, DataHolder, StandaloneMode } from './Data';
|
|
5
5
|
import { Journal } from './Journal';
|
|
6
6
|
import { Monitor } from './Monitor';
|
|
7
|
-
export declare abstract class
|
|
7
|
+
export declare abstract class ReactiveObject {
|
|
8
8
|
constructor();
|
|
9
9
|
[Symbol.toStringTag](): string;
|
|
10
10
|
}
|
|
@@ -37,11 +37,11 @@ export declare class Hooks implements ProxyHandler<DataHolder> {
|
|
|
37
37
|
has(h: DataHolder, m: MemberName): boolean;
|
|
38
38
|
getOwnPropertyDescriptor(h: DataHolder, m: MemberName): PropertyDescriptor | undefined;
|
|
39
39
|
ownKeys(h: DataHolder): Array<string | symbol>;
|
|
40
|
-
static decorateData(
|
|
40
|
+
static decorateData(reactive: boolean, proto: any, m: MemberName): any;
|
|
41
41
|
static decorateOperation(implicit: boolean, decorator: Function, options: Partial<MemberOptions>, proto: any, member: MemberName, pd: PropertyDescriptor | undefined): any;
|
|
42
42
|
static decorateOperationParametrized(decorator: Function, options: Partial<MemberOptions>): F<any>;
|
|
43
43
|
static acquireDataHolder(obj: any): DataHolder;
|
|
44
|
-
static
|
|
44
|
+
static createDataHolderForReactiveObject(proto: any, data: any, blank: any, hint: string): DataHolder;
|
|
45
45
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
46
46
|
static sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
47
47
|
static setHint<T>(obj: T, hint: string | undefined): T;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Hooks = exports.OptionsImpl = exports.
|
|
3
|
+
exports.Hooks = exports.OptionsImpl = exports.ReactiveObject = void 0;
|
|
4
4
|
const Utils_1 = require("../util/Utils");
|
|
5
5
|
const Dbg_1 = require("../util/Dbg");
|
|
6
6
|
const Options_1 = require("../Options");
|
|
7
7
|
const Data_1 = require("./Data");
|
|
8
8
|
const Snapshot_1 = require("./Snapshot");
|
|
9
|
-
class
|
|
9
|
+
class ReactiveObject {
|
|
10
10
|
constructor() {
|
|
11
11
|
const proto = new.target.prototype;
|
|
12
12
|
const initial = Data_1.Meta.getFrom(proto, Data_1.Meta.Initial);
|
|
13
|
-
const h = Hooks.
|
|
13
|
+
const h = Hooks.createDataHolderForReactiveObject(proto, this, initial, new.target.name);
|
|
14
14
|
return h.proxy;
|
|
15
15
|
}
|
|
16
16
|
[Symbol.toStringTag]() {
|
|
@@ -18,7 +18,7 @@ class SubscribingObject {
|
|
|
18
18
|
return Snapshot_1.Dump.obj(h);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.
|
|
21
|
+
exports.ReactiveObject = ReactiveObject;
|
|
22
22
|
const DEFAULT_OPTIONS = Object.freeze({
|
|
23
23
|
kind: Options_1.Kind.Plain,
|
|
24
24
|
standalone: false,
|
|
@@ -117,8 +117,8 @@ class Hooks {
|
|
|
117
117
|
}
|
|
118
118
|
return result;
|
|
119
119
|
}
|
|
120
|
-
static decorateData(
|
|
121
|
-
if (
|
|
120
|
+
static decorateData(reactive, proto, m) {
|
|
121
|
+
if (reactive) {
|
|
122
122
|
const get = function () {
|
|
123
123
|
const h = Hooks.acquireDataHolder(this);
|
|
124
124
|
return Hooks.proxy.get(h, m, this);
|
|
@@ -132,7 +132,7 @@ class Hooks {
|
|
|
132
132
|
return Object.defineProperty(proto, m, { get, set, enumerable, configurable });
|
|
133
133
|
}
|
|
134
134
|
else
|
|
135
|
-
Data_1.Meta.acquire(proto, Data_1.Meta.Initial)[m] = Data_1.Meta.
|
|
135
|
+
Data_1.Meta.acquire(proto, Data_1.Meta.Initial)[m] = Data_1.Meta.Nonreactive;
|
|
136
136
|
}
|
|
137
137
|
static decorateOperation(implicit, decorator, options, proto, member, pd) {
|
|
138
138
|
var _a, _b, _c, _d;
|
|
@@ -180,7 +180,7 @@ class Hooks {
|
|
|
180
180
|
}
|
|
181
181
|
return h;
|
|
182
182
|
}
|
|
183
|
-
static
|
|
183
|
+
static createDataHolderForReactiveObject(proto, data, blank, hint) {
|
|
184
184
|
const ctx = Snapshot_1.Snapshot.edit();
|
|
185
185
|
const h = new Data_1.DataHolder(data, undefined, Hooks.proxy, Snapshot_1.ROOT_REV, hint);
|
|
186
186
|
ctx.getEditableRevision(h, Data_1.Meta.Holder, blank);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactiveObject } from './Hooks';
|
|
2
2
|
import { DataHolder, DataRevision, PatchSet } from './Data';
|
|
3
3
|
export declare type Saver = (patch: PatchSet) => Promise<void>;
|
|
4
|
-
export declare abstract class Journal extends
|
|
4
|
+
export declare abstract class Journal extends ReactiveObject {
|
|
5
5
|
abstract capacity: number;
|
|
6
6
|
abstract readonly edits: ReadonlyArray<PatchSet>;
|
|
7
7
|
abstract readonly unsaved: PatchSet;
|
|
@@ -6,7 +6,7 @@ const Data_1 = require("./Data");
|
|
|
6
6
|
const Snapshot_1 = require("./Snapshot");
|
|
7
7
|
const Transaction_1 = require("./Transaction");
|
|
8
8
|
const Sealant_1 = require("../util/Sealant");
|
|
9
|
-
class Journal extends Hooks_1.
|
|
9
|
+
class Journal extends Hooks_1.ReactiveObject {
|
|
10
10
|
static create() { return new JournalImpl(); }
|
|
11
11
|
}
|
|
12
12
|
exports.Journal = Journal;
|
|
@@ -4,7 +4,7 @@ export declare abstract class Meta {
|
|
|
4
4
|
static readonly Disposed: unique symbol;
|
|
5
5
|
static readonly Initial: unique symbol;
|
|
6
6
|
static readonly Reactions: unique symbol;
|
|
7
|
-
static readonly
|
|
7
|
+
static readonly Nonreactive: unique symbol;
|
|
8
8
|
static readonly Undefined: unique symbol;
|
|
9
9
|
static get<T>(obj: any, sym: symbol): T;
|
|
10
10
|
static set(obj: any, sym: symbol, value: any): any;
|
|
@@ -29,5 +29,5 @@ Meta.Controller = Symbol('rxController');
|
|
|
29
29
|
Meta.Disposed = Symbol('rxDisposed');
|
|
30
30
|
Meta.Initial = Symbol('rxInitial');
|
|
31
31
|
Meta.Reactions = Symbol('rxReactions');
|
|
32
|
-
Meta.
|
|
32
|
+
Meta.Nonreactive = Symbol('rxNonreactive');
|
|
33
33
|
Meta.Undefined = Symbol('rxUndefined');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Worker } from '../Worker';
|
|
2
|
-
import {
|
|
3
|
-
export declare abstract class Monitor extends
|
|
2
|
+
import { ReactiveObject } from './Hooks';
|
|
3
|
+
export declare abstract class Monitor extends ReactiveObject {
|
|
4
4
|
abstract readonly isActive: boolean;
|
|
5
5
|
abstract readonly counter: number;
|
|
6
6
|
abstract readonly workers: ReadonlySet<Worker>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MonitorImpl = exports.Monitor = void 0;
|
|
4
4
|
const Hooks_1 = require("./Hooks");
|
|
5
5
|
const Transaction_1 = require("./Transaction");
|
|
6
|
-
class Monitor extends Hooks_1.
|
|
6
|
+
class Monitor extends Hooks_1.ReactiveObject {
|
|
7
7
|
static create(hint, activationDelay, deactivationDelay, durationResolution) {
|
|
8
8
|
return MonitorImpl.create(hint, activationDelay, deactivationDelay, durationResolution);
|
|
9
9
|
}
|
|
@@ -9,7 +9,7 @@ export declare class OperationController extends Controller<any> {
|
|
|
9
9
|
readonly memberName: MemberName;
|
|
10
10
|
configure(options: Partial<MemberOptions>): MemberOptions;
|
|
11
11
|
get options(): MemberOptions;
|
|
12
|
-
get
|
|
12
|
+
get nonreactive(): any;
|
|
13
13
|
get args(): ReadonlyArray<any>;
|
|
14
14
|
get result(): any;
|
|
15
15
|
get error(): boolean;
|
|
@@ -21,7 +21,7 @@ class OperationController extends Controller_1.Controller {
|
|
|
21
21
|
}
|
|
22
22
|
configure(options) { return OperationController.configureImpl(this, options); }
|
|
23
23
|
get options() { return this.peek(undefined).operation.options; }
|
|
24
|
-
get
|
|
24
|
+
get nonreactive() { return this.peek(undefined).operation.content; }
|
|
25
25
|
get args() { return this.use().operation.args; }
|
|
26
26
|
get result() { return this.useOrRun(true, undefined).content; }
|
|
27
27
|
get error() { return this.use().operation.error; }
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(Data_1.DataHolder.prototype, '#this', {
|
|
|
19
19
|
const v = data[m];
|
|
20
20
|
if (v instanceof Data_1.Subscription)
|
|
21
21
|
result[m] = v.content;
|
|
22
|
-
else if (v === Data_1.Meta.
|
|
22
|
+
else if (v === Data_1.Meta.Nonreactive)
|
|
23
23
|
result[m] = this.data[m];
|
|
24
24
|
else
|
|
25
25
|
result[m] = v;
|
|
@@ -64,7 +64,7 @@ class Snapshot {
|
|
|
64
64
|
getEditableRevision(h, m, value, token) {
|
|
65
65
|
let r = this.seekRevision(h, m);
|
|
66
66
|
const existing = r.data[m];
|
|
67
|
-
if (existing !== Data_1.Meta.
|
|
67
|
+
if (existing !== Data_1.Meta.Nonreactive) {
|
|
68
68
|
if (this.isNewRevisionRequired(h, r, m, existing, value, token)) {
|
|
69
69
|
const data = Object.assign({}, m === Data_1.Meta.Holder ? value : r.data);
|
|
70
70
|
Reflect.set(data, Data_1.Meta.Holder, h);
|
|
@@ -99,7 +99,7 @@ class Snapshot {
|
|
|
99
99
|
}
|
|
100
100
|
isNewRevisionRequired(h, r, m, existing, value, token) {
|
|
101
101
|
if (this.sealed && r.snapshot !== exports.ROOT_REV.snapshot)
|
|
102
|
-
throw (0, Dbg_1.misuse)(`
|
|
102
|
+
throw (0, Dbg_1.misuse)(`reactive property ${Dump.obj(h, m)} can only be modified inside transaction`);
|
|
103
103
|
if (m !== Data_1.Meta.Holder && value !== Data_1.Meta.Holder) {
|
|
104
104
|
if (r.snapshot !== this || r.former.revision !== exports.ROOT_REV) {
|
|
105
105
|
if (this.options.token !== undefined && token !== this.options.token)
|