reactronic 0.24.250 → 0.24.261
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.
|
@@ -35,7 +35,7 @@ export declare abstract class RxNode<E = unknown> {
|
|
|
35
35
|
static readonly longFrameDuration = 300;
|
|
36
36
|
static currentUpdatePriority: Priority;
|
|
37
37
|
static frameDuration: number;
|
|
38
|
-
static
|
|
38
|
+
static child<E = void>(driver: RxNodeDriver<E>, declaration?: RxNodeDecl<E>, preset?: RxNodeDecl<E>): RxNode<E>;
|
|
39
39
|
static get isFirstUpdate(): boolean;
|
|
40
40
|
static get key(): string;
|
|
41
41
|
static get stamp(): number;
|
|
@@ -55,11 +55,11 @@ export declare abstract class RxNode<E = unknown> {
|
|
|
55
55
|
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
56
56
|
}
|
|
57
57
|
export type RxNodeDecl<E = unknown> = {
|
|
58
|
-
|
|
58
|
+
onChange?: Delegate<E>;
|
|
59
59
|
key?: string;
|
|
60
60
|
mode?: Mode;
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
onCreate?: Delegate<E>;
|
|
62
|
+
onDestroy?: Delegate<E>;
|
|
63
63
|
triggers?: unknown;
|
|
64
64
|
preset?: RxNodeDecl<E>;
|
|
65
65
|
};
|
|
@@ -68,10 +68,11 @@ export type RxNodeDriver<E = unknown> = {
|
|
|
68
68
|
readonly isPartitionSeparator: boolean;
|
|
69
69
|
readonly predefine?: SimpleDelegate<E>;
|
|
70
70
|
allocate(node: RxNode<E>): E;
|
|
71
|
-
|
|
71
|
+
create(node: RxNode<E>): void;
|
|
72
|
+
destroy(node: RxNode<E>, isLeader: boolean): boolean;
|
|
72
73
|
mount(node: RxNode<E>): void;
|
|
73
74
|
update(node: RxNode<E>): void | Promise<void>;
|
|
74
|
-
|
|
75
|
+
child(driver: RxNodeDriver<any>, declaration?: RxNodeDecl<any>, preset?: RxNodeDecl<any>): void;
|
|
75
76
|
};
|
|
76
77
|
export type RxNodeContext<T extends Object = Object> = {
|
|
77
78
|
value: T;
|
|
@@ -82,10 +83,11 @@ export declare abstract class BaseDriver<E = unknown> implements RxNodeDriver<E>
|
|
|
82
83
|
readonly predefine?: SimpleDelegate<E, void> | undefined;
|
|
83
84
|
constructor(name: string, isPartitionSeparator: boolean, predefine?: SimpleDelegate<E, void> | undefined);
|
|
84
85
|
abstract allocate(node: RxNode<E>): E;
|
|
85
|
-
|
|
86
|
+
create(node: RxNode<E>): void;
|
|
87
|
+
destroy(node: RxNode<E>, isLeader: boolean): boolean;
|
|
86
88
|
mount(node: RxNode<E>): void;
|
|
87
89
|
update(node: RxNode<E>): void | Promise<void>;
|
|
88
|
-
|
|
90
|
+
child(driver: RxNodeDriver<any>, declaration?: RxNodeDecl<any>, preset?: RxNodeDecl<any>): void;
|
|
89
91
|
}
|
|
90
92
|
export declare class RxNodeVariable<T extends Object = Object> {
|
|
91
93
|
readonly defaultValue: T | undefined;
|
|
@@ -35,7 +35,7 @@ export var Priority;
|
|
|
35
35
|
Priority[Priority["background"] = 2] = "background";
|
|
36
36
|
})(Priority || (Priority = {}));
|
|
37
37
|
export class RxNode {
|
|
38
|
-
static
|
|
38
|
+
static child(driver, declaration, preset) {
|
|
39
39
|
var _a;
|
|
40
40
|
let result;
|
|
41
41
|
if (declaration)
|
|
@@ -45,6 +45,7 @@ export class RxNode {
|
|
|
45
45
|
let key = declaration.key;
|
|
46
46
|
const owner = gOwnSeat === null || gOwnSeat === void 0 ? void 0 : gOwnSeat.instance;
|
|
47
47
|
if (owner) {
|
|
48
|
+
owner.driver.child(driver, declaration, preset);
|
|
48
49
|
let existing = undefined;
|
|
49
50
|
const children = owner.children;
|
|
50
51
|
if (driver.isPartitionSeparator) {
|
|
@@ -155,19 +156,21 @@ export class BaseDriver {
|
|
|
155
156
|
this.isPartitionSeparator = isPartitionSeparator;
|
|
156
157
|
this.predefine = predefine;
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
+
create(node) {
|
|
159
160
|
var _a;
|
|
160
161
|
(_a = this.predefine) === null || _a === void 0 ? void 0 : _a.call(this, node.element);
|
|
161
|
-
|
|
162
|
+
invokeOnCreateViaPresetChain(node.element, node.declaration);
|
|
163
|
+
}
|
|
164
|
+
destroy(node, isLeader) {
|
|
165
|
+
invokeOnDestroyViaPresetChain(node.element, node.declaration);
|
|
166
|
+
return isLeader;
|
|
162
167
|
}
|
|
163
168
|
mount(node) {
|
|
164
169
|
}
|
|
165
170
|
update(node) {
|
|
166
|
-
|
|
171
|
+
invokeOnChangeViaPresetChain(node.element, node.declaration);
|
|
167
172
|
}
|
|
168
|
-
|
|
169
|
-
deactivateViaPresetChain(node.element, node.declaration);
|
|
170
|
-
return isLeader;
|
|
173
|
+
child(driver, declaration, preset) {
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
export class RxNodeVariable {
|
|
@@ -198,29 +201,29 @@ function getModeViaPresetChain(declaration) {
|
|
|
198
201
|
var _a;
|
|
199
202
|
return (_a = declaration === null || declaration === void 0 ? void 0 : declaration.mode) !== null && _a !== void 0 ? _a : ((declaration === null || declaration === void 0 ? void 0 : declaration.preset) ? getModeViaPresetChain(declaration === null || declaration === void 0 ? void 0 : declaration.preset) : Mode.default);
|
|
200
203
|
}
|
|
201
|
-
function
|
|
204
|
+
function invokeOnCreateViaPresetChain(element, declaration) {
|
|
202
205
|
const preset = declaration.preset;
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
+
const onCreate = declaration.onCreate;
|
|
207
|
+
if (onCreate)
|
|
208
|
+
onCreate(element, preset ? () => invokeOnCreateViaPresetChain(element, preset) : NOP);
|
|
206
209
|
else if (preset)
|
|
207
|
-
|
|
210
|
+
invokeOnCreateViaPresetChain(element, preset);
|
|
208
211
|
}
|
|
209
|
-
function
|
|
212
|
+
function invokeOnChangeViaPresetChain(element, declaration) {
|
|
210
213
|
const preset = declaration.preset;
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
+
const onChange = declaration.onChange;
|
|
215
|
+
if (onChange)
|
|
216
|
+
onChange(element, preset ? () => invokeOnChangeViaPresetChain(element, preset) : NOP);
|
|
214
217
|
else if (preset)
|
|
215
|
-
|
|
218
|
+
invokeOnChangeViaPresetChain(element, preset);
|
|
216
219
|
}
|
|
217
|
-
function
|
|
220
|
+
function invokeOnDestroyViaPresetChain(element, declaration) {
|
|
218
221
|
const preset = declaration.preset;
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
+
const onDestroy = declaration.onDestroy;
|
|
223
|
+
if (onDestroy)
|
|
224
|
+
onDestroy(element, preset ? () => invokeOnDestroyViaPresetChain(element, preset) : NOP);
|
|
222
225
|
else if (preset)
|
|
223
|
-
|
|
226
|
+
invokeOnDestroyViaPresetChain(element, preset);
|
|
224
227
|
}
|
|
225
228
|
class RxNodeContextImpl extends ObservableObject {
|
|
226
229
|
constructor(variable, value) {
|
|
@@ -465,7 +468,7 @@ function mountOrRemountIfNecessary(node) {
|
|
|
465
468
|
if (node.stamp === Number.MAX_SAFE_INTEGER) {
|
|
466
469
|
unobs(() => {
|
|
467
470
|
node.stamp = Number.MAX_SAFE_INTEGER - 1;
|
|
468
|
-
driver.
|
|
471
|
+
driver.create(node);
|
|
469
472
|
if (!node.has(Mode.manualMount)) {
|
|
470
473
|
node.stamp = 0;
|
|
471
474
|
if (node.host !== node)
|
|
@@ -510,7 +513,7 @@ function triggerDeactivation(seat, isLeader, individual) {
|
|
|
510
513
|
if (individual && node.key !== node.declaration.key && !driver.isPartitionSeparator)
|
|
511
514
|
console.log(`WARNING: it is recommended to assign explicit key for conditional element in order to avoid unexpected side effects: ${node.key}`);
|
|
512
515
|
node.stamp = ~node.stamp;
|
|
513
|
-
const childrenAreLeaders = unobs(() => driver.
|
|
516
|
+
const childrenAreLeaders = unobs(() => driver.destroy(node, isLeader));
|
|
514
517
|
if (node.has(Mode.independentUpdate)) {
|
|
515
518
|
seat.aux = undefined;
|
|
516
519
|
const last = gLastToDispose;
|