reactronic 0.23.107 → 0.23.109
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/build/dist/source/Reaction.d.ts +18 -0
- package/build/dist/source/Reaction.js +24 -0
- package/build/dist/source/Rx.d.ts +3 -2
- package/build/dist/source/Rx.js +10 -6
- package/build/dist/source/api.d.ts +2 -2
- package/build/dist/source/api.js +1 -2
- package/build/dist/source/impl/Changeset.d.ts +5 -5
- package/build/dist/source/impl/Changeset.js +9 -9
- package/build/dist/source/impl/Data.d.ts +4 -4
- package/build/dist/source/impl/Data.js +1 -1
- package/build/dist/source/impl/Journal.js +2 -2
- package/build/dist/source/impl/Mvcc.js +6 -6
- package/build/dist/source/impl/{Operation.d.ts → Reaction.d.ts} +21 -21
- package/build/dist/source/impl/{Operation.js → Reaction.js} +192 -194
- package/package.json +1 -1
- package/build/dist/source/Controller.d.ts +0 -12
- package/build/dist/source/Controller.js +0 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { F } from './util/Utils.js';
|
|
2
|
+
import { MemberOptions } from './Options.js';
|
|
3
|
+
export interface AbstractReaction<T> {
|
|
4
|
+
readonly options: MemberOptions;
|
|
5
|
+
readonly args: ReadonlyArray<any>;
|
|
6
|
+
readonly result: T;
|
|
7
|
+
readonly error: any;
|
|
8
|
+
readonly stamp: number;
|
|
9
|
+
readonly isUpToDate: boolean;
|
|
10
|
+
configure(options: Partial<MemberOptions>): MemberOptions;
|
|
11
|
+
markObsolete(): void;
|
|
12
|
+
pullLastResult(args?: any[]): T | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class Reaction<T> {
|
|
15
|
+
protected action: F<T>;
|
|
16
|
+
constructor(action: F<T>);
|
|
17
|
+
protected launch(): T;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { reactive } from 'Rx.js';
|
|
11
|
+
export class Reaction {
|
|
12
|
+
constructor(action) {
|
|
13
|
+
this.action = action;
|
|
14
|
+
}
|
|
15
|
+
launch() {
|
|
16
|
+
return this.action();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
reactive,
|
|
21
|
+
__metadata("design:type", Function),
|
|
22
|
+
__metadata("design:paramtypes", []),
|
|
23
|
+
__metadata("design:returntype", Object)
|
|
24
|
+
], Reaction.prototype, "launch", null);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { F } from './util/Utils.js';
|
|
2
|
-
import {
|
|
2
|
+
import { AbstractReaction } from './Reaction.js';
|
|
3
3
|
import { MemberOptions, LoggingOptions, ProfilingOptions } from './Options.js';
|
|
4
4
|
export declare class Rx {
|
|
5
5
|
static why(brief?: boolean): string;
|
|
6
|
-
static
|
|
6
|
+
static getReaction<T>(method: F<T>): AbstractReaction<T>;
|
|
7
7
|
static pullLastResult<T>(method: F<Promise<T>>, args?: any[]): T | undefined;
|
|
8
8
|
static configureCurrentOperation(options: Partial<MemberOptions>): MemberOptions;
|
|
9
9
|
static getRevisionOf(obj: any): number;
|
|
@@ -18,6 +18,7 @@ export declare class Rx {
|
|
|
18
18
|
static getLoggingHint<T extends object>(obj: T, full?: boolean): string | undefined;
|
|
19
19
|
static setProfilingMode(isOn: boolean, options?: Partial<ProfilingOptions>): void;
|
|
20
20
|
}
|
|
21
|
+
export declare function transaction<T>(action: F<T>, ...args: any[]): T;
|
|
21
22
|
export declare function nonreactive<T>(func: F<T>, ...args: any[]): T;
|
|
22
23
|
export declare function sensitive<T>(sensitivity: boolean, func: F<T>, ...args: any[]): T;
|
|
23
24
|
export declare function raw(proto: object, prop: PropertyKey): any;
|
package/build/dist/source/Rx.js
CHANGED
|
@@ -3,12 +3,13 @@ import { Kind } from './Options.js';
|
|
|
3
3
|
import { Meta, ObjectHandle } from './impl/Data.js';
|
|
4
4
|
import { Changeset } from './impl/Changeset.js';
|
|
5
5
|
import { Mvcc } from './impl/Mvcc.js';
|
|
6
|
-
import {
|
|
6
|
+
import { Transaction } from './impl/Transaction.js';
|
|
7
|
+
import { ReactionImpl } from './impl/Reaction.js';
|
|
7
8
|
export class Rx {
|
|
8
|
-
static why(brief = false) { return brief ?
|
|
9
|
-
static
|
|
10
|
-
static pullLastResult(method, args) { return Rx.
|
|
11
|
-
static configureCurrentOperation(options) { return
|
|
9
|
+
static why(brief = false) { return brief ? ReactionImpl.briefWhy() : ReactionImpl.why(); }
|
|
10
|
+
static getReaction(method) { return ReactionImpl.getControllerOf(method); }
|
|
11
|
+
static pullLastResult(method, args) { return Rx.getReaction(method).pullLastResult(args); }
|
|
12
|
+
static configureCurrentOperation(options) { return ReactionImpl.configureImpl(undefined, options); }
|
|
12
13
|
static getRevisionOf(obj) { return obj[Meta.Revision]; }
|
|
13
14
|
static takeSnapshot(obj) { return Changeset.takeSnapshot(obj); }
|
|
14
15
|
static dispose(obj) { Changeset.dispose(obj); }
|
|
@@ -21,8 +22,11 @@ export class Rx {
|
|
|
21
22
|
static getLoggingHint(obj, full = false) { return ObjectHandle.getHint(obj, full); }
|
|
22
23
|
static setProfilingMode(isOn, options) { Mvcc.setProfilingMode(isOn, options); }
|
|
23
24
|
}
|
|
25
|
+
export function transaction(action, ...args) {
|
|
26
|
+
return Transaction.run(null, action, ...args);
|
|
27
|
+
}
|
|
24
28
|
export function nonreactive(func, ...args) {
|
|
25
|
-
return
|
|
29
|
+
return ReactionImpl.proceedWithinGivenLaunch(undefined, func, ...args);
|
|
26
30
|
}
|
|
27
31
|
export function sensitive(sensitivity, func, ...args) {
|
|
28
32
|
return Mvcc.sensitive(sensitivity, func, ...args);
|
|
@@ -7,7 +7,7 @@ export { SealedSet } from './util/SealedSet.js';
|
|
|
7
7
|
export { Kind, Reentrance, LoggingLevel } from './Options.js';
|
|
8
8
|
export type { MemberOptions, SnapshotOptions, LoggingOptions, ProfilingOptions } from './Options.js';
|
|
9
9
|
export type { Worker } from './Worker.js';
|
|
10
|
-
export {
|
|
10
|
+
export type { AbstractReaction } from './Reaction.js';
|
|
11
11
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from './Ref.js';
|
|
12
12
|
export type { BoolOnly, GivenTypeOnly } from './Ref.js';
|
|
13
13
|
export { TransactionalObject, ObservableObject } from './impl/Mvcc.js';
|
|
@@ -17,5 +17,5 @@ export { Changeset } from './impl/Changeset.js';
|
|
|
17
17
|
export { Transaction } from './impl/Transaction.js';
|
|
18
18
|
export { Monitor } from './impl/Monitor.js';
|
|
19
19
|
export { Journal } from './impl/Journal.js';
|
|
20
|
-
export { Rx, raw, observable, transactional, reactive, cached, nonreactive, sensitive, options } from './Rx.js';
|
|
20
|
+
export { Rx, raw, observable, transactional, reactive, cached, transaction, nonreactive, sensitive, options } from './Rx.js';
|
|
21
21
|
export { Clock } from './Clock.js';
|
package/build/dist/source/api.js
CHANGED
|
@@ -4,7 +4,6 @@ export { SealedArray } from './util/SealedArray.js';
|
|
|
4
4
|
export { SealedMap } from './util/SealedMap.js';
|
|
5
5
|
export { SealedSet } from './util/SealedSet.js';
|
|
6
6
|
export { Kind, Reentrance, LoggingLevel } from './Options.js';
|
|
7
|
-
export { Controller } from './Controller.js';
|
|
8
7
|
export { Ref, ToggleRef, refs, toggleRefs, customToggleRefs } from './Ref.js';
|
|
9
8
|
export { TransactionalObject, ObservableObject } from './impl/Mvcc.js';
|
|
10
9
|
export { TransactionalArray, ObservableArray } from './impl/MvccArray.js';
|
|
@@ -13,5 +12,5 @@ export { Changeset } from './impl/Changeset.js';
|
|
|
13
12
|
export { Transaction } from './impl/Transaction.js';
|
|
14
13
|
export { Monitor } from './impl/Monitor.js';
|
|
15
14
|
export { Journal } from './impl/Journal.js';
|
|
16
|
-
export { Rx, raw, observable, transactional, reactive, cached, nonreactive, sensitive, options } from './Rx.js';
|
|
15
|
+
export { Rx, raw, observable, transactional, reactive, cached, transaction, nonreactive, sensitive, options } from './Rx.js';
|
|
17
16
|
export { Clock } from './Clock.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kind, SnapshotOptions } from '../Options.js';
|
|
2
|
-
import { AbstractChangeset, ObjectSnapshot, MemberName, ObjectHandle,
|
|
2
|
+
import { AbstractChangeset, ObjectSnapshot, MemberName, ObjectHandle, MvccValue, Observer } from './Data.js';
|
|
3
3
|
export declare const MAX_REVISION: number;
|
|
4
4
|
export declare const UNDEFINED_REVISION: number;
|
|
5
5
|
export declare class Changeset implements AbstractChangeset {
|
|
@@ -18,12 +18,12 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
18
18
|
private revision;
|
|
19
19
|
private bumper;
|
|
20
20
|
items: Map<ObjectHandle, ObjectSnapshot>;
|
|
21
|
-
|
|
21
|
+
obsolete: Observer[];
|
|
22
22
|
sealed: boolean;
|
|
23
23
|
constructor(options: SnapshotOptions | null);
|
|
24
24
|
static current: () => Changeset;
|
|
25
25
|
static edit: () => Changeset;
|
|
26
|
-
static markUsed: (observable:
|
|
26
|
+
static markUsed: (observable: MvccValue, os: ObjectSnapshot, m: MemberName, h: ObjectHandle, kind: Kind, weak: boolean) => void;
|
|
27
27
|
static markEdited: (oldValue: any, newValue: any, edited: boolean, os: ObjectSnapshot, m: MemberName, h: ObjectHandle) => void;
|
|
28
28
|
static isConflicting: (oldValue: any, newValue: any) => boolean;
|
|
29
29
|
static propagateAllChangesThroughSubscriptions: (changeset: Changeset) => void;
|
|
@@ -42,7 +42,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
42
42
|
private merge;
|
|
43
43
|
applyOrDiscard(error?: any): Array<Observer>;
|
|
44
44
|
static sealObjectSnapshot(h: ObjectHandle, os: ObjectSnapshot): void;
|
|
45
|
-
static
|
|
45
|
+
static sealMvccValue(o: MvccValue | symbol, m: MemberName, typeName: string): void;
|
|
46
46
|
static freezeObjectSnapshot(os: ObjectSnapshot): ObjectSnapshot;
|
|
47
47
|
triggerGarbageCollection(): void;
|
|
48
48
|
private unlinkHistory;
|
|
@@ -51,7 +51,7 @@ export declare class Changeset implements AbstractChangeset {
|
|
|
51
51
|
export declare class Dump {
|
|
52
52
|
static valueHint: (value: any) => string;
|
|
53
53
|
static obj(h: ObjectHandle | undefined, m?: MemberName | undefined, stamp?: number, snapshotId?: number, originSnapshotId?: number, value?: any): string;
|
|
54
|
-
static snapshot2(h: ObjectHandle, s: AbstractChangeset, m?: MemberName, o?:
|
|
54
|
+
static snapshot2(h: ObjectHandle, s: AbstractChangeset, m?: MemberName, o?: MvccValue): string;
|
|
55
55
|
static snapshot(os: ObjectSnapshot, m?: MemberName): string;
|
|
56
56
|
static conflicts(conflicts: ObjectSnapshot[]): string;
|
|
57
57
|
static conflictingMemberHint(m: MemberName, ours: ObjectSnapshot, theirs: ObjectSnapshot): string;
|
|
@@ -4,7 +4,7 @@ import { Sealant } from '../util/Sealant.js';
|
|
|
4
4
|
import { SealedArray } from '../util/SealedArray.js';
|
|
5
5
|
import { SealedMap } from '../util/SealedMap.js';
|
|
6
6
|
import { SealedSet } from '../util/SealedSet.js';
|
|
7
|
-
import { ObjectSnapshot, ObjectHandle,
|
|
7
|
+
import { ObjectSnapshot, ObjectHandle, MvccValue, Meta } from './Data.js';
|
|
8
8
|
export const MAX_REVISION = Number.MAX_SAFE_INTEGER;
|
|
9
9
|
export const UNDEFINED_REVISION = MAX_REVISION - 1;
|
|
10
10
|
Object.defineProperty(ObjectHandle.prototype, '#this#', {
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(ObjectHandle.prototype, '#this#', {
|
|
|
14
14
|
const data = Changeset.current().getObjectSnapshot(this, '#this#').data;
|
|
15
15
|
for (const m in data) {
|
|
16
16
|
const v = data[m];
|
|
17
|
-
if (v instanceof
|
|
17
|
+
if (v instanceof MvccValue)
|
|
18
18
|
result[m] = v.content;
|
|
19
19
|
else if (v === Meta.Raw)
|
|
20
20
|
result[m] = this.data[m];
|
|
@@ -35,7 +35,7 @@ export class Changeset {
|
|
|
35
35
|
this.revision = UNDEFINED_REVISION;
|
|
36
36
|
this.bumper = 100;
|
|
37
37
|
this.items = new Map();
|
|
38
|
-
this.
|
|
38
|
+
this.obsolete = [];
|
|
39
39
|
this.sealed = false;
|
|
40
40
|
}
|
|
41
41
|
lookupObjectSnapshot(h, m) {
|
|
@@ -67,7 +67,7 @@ export class Changeset {
|
|
|
67
67
|
const revision = m === Meta.Handle ? 1 : os.revision + 1;
|
|
68
68
|
const data = Object.assign({}, m === Meta.Handle ? value : os.data);
|
|
69
69
|
Meta.set(data, Meta.Handle, h);
|
|
70
|
-
Meta.set(data, Meta.Revision, new
|
|
70
|
+
Meta.set(data, Meta.Revision, new MvccValue(revision));
|
|
71
71
|
os = new ObjectSnapshot(this, os, data);
|
|
72
72
|
this.items.set(h, os);
|
|
73
73
|
h.editing = os;
|
|
@@ -214,19 +214,19 @@ export class Changeset {
|
|
|
214
214
|
}
|
|
215
215
|
if (!error)
|
|
216
216
|
Changeset.propagateAllChangesThroughSubscriptions(this);
|
|
217
|
-
return this.
|
|
217
|
+
return this.obsolete;
|
|
218
218
|
}
|
|
219
219
|
static sealObjectSnapshot(h, os) {
|
|
220
220
|
if (!os.disposed)
|
|
221
|
-
os.changes.forEach((o, m) => Changeset.
|
|
221
|
+
os.changes.forEach((o, m) => Changeset.sealMvccValue(os.data[m], m, h.proxy.constructor.name));
|
|
222
222
|
else
|
|
223
223
|
for (const m in os.former.snapshot.data)
|
|
224
224
|
os.data[m] = Meta.Undefined;
|
|
225
225
|
if (Log.isOn)
|
|
226
226
|
Changeset.freezeObjectSnapshot(os);
|
|
227
227
|
}
|
|
228
|
-
static
|
|
229
|
-
if (o instanceof
|
|
228
|
+
static sealMvccValue(o, m, typeName) {
|
|
229
|
+
if (o instanceof MvccValue) {
|
|
230
230
|
const value = o.content;
|
|
231
231
|
if (value !== undefined && value !== null) {
|
|
232
232
|
const sealedType = Object.getPrototypeOf(value)[Sealant.SealedType];
|
|
@@ -276,7 +276,7 @@ export class Changeset {
|
|
|
276
276
|
os.former.snapshot = EMPTY_SNAPSHOT;
|
|
277
277
|
});
|
|
278
278
|
this.items = EMPTY_MAP;
|
|
279
|
-
this.
|
|
279
|
+
this.obsolete = EMPTY_ARRAY;
|
|
280
280
|
if (Log.isOn)
|
|
281
281
|
Object.freeze(this);
|
|
282
282
|
}
|
|
@@ -5,7 +5,7 @@ export interface AbstractChangeset {
|
|
|
5
5
|
readonly timestamp: number;
|
|
6
6
|
readonly sealed: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class MvccValue {
|
|
9
9
|
content: any;
|
|
10
10
|
observers?: Set<Observer>;
|
|
11
11
|
get isOperation(): boolean;
|
|
@@ -15,11 +15,11 @@ export declare class ObservableValue {
|
|
|
15
15
|
export type SeparationMode = boolean | 'isolated' | 'disposal';
|
|
16
16
|
export interface Observer {
|
|
17
17
|
readonly order: number;
|
|
18
|
-
readonly observables: Map<
|
|
18
|
+
readonly observables: Map<MvccValue, Subscription> | undefined;
|
|
19
19
|
readonly obsoleteSince: number;
|
|
20
20
|
hint(nop?: boolean): string;
|
|
21
|
-
markObsoleteDueTo(observable:
|
|
22
|
-
|
|
21
|
+
markObsoleteDueTo(observable: MvccValue, m: MemberName, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number, reactive: Array<Observer>): void;
|
|
22
|
+
relaunchIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
23
23
|
}
|
|
24
24
|
export type MemberName = PropertyKey;
|
|
25
25
|
export interface Subscription {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Log } from '../util/Dbg.js';
|
|
2
2
|
import { Meta } from './Meta.js';
|
|
3
3
|
export { Meta } from './Meta.js';
|
|
4
|
-
export class
|
|
4
|
+
export class MvccValue {
|
|
5
5
|
get isOperation() { return false; }
|
|
6
6
|
get originSnapshotId() { return 0; }
|
|
7
7
|
constructor(content) { this.content = content; }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObservableObject } from './Mvcc.js';
|
|
2
|
-
import { Meta,
|
|
2
|
+
import { Meta, MvccValue } from './Data.js';
|
|
3
3
|
import { Changeset, EMPTY_SNAPSHOT } from './Changeset.js';
|
|
4
4
|
import { Transaction } from './Transaction.js';
|
|
5
5
|
import { Sealant } from '../util/Sealant.js';
|
|
@@ -99,7 +99,7 @@ export class JournalImpl extends Journal {
|
|
|
99
99
|
const value = undoing ? vp.formerValue : vp.freshValue;
|
|
100
100
|
const os = ctx.getEditableObjectSnapshot(h, m, value);
|
|
101
101
|
if (os.changeset === ctx) {
|
|
102
|
-
os.data[m] = new
|
|
102
|
+
os.data[m] = new MvccValue(value);
|
|
103
103
|
const existing = os.former.snapshot.data[m];
|
|
104
104
|
Changeset.markEdited(existing, value, existing !== value, os, m, h);
|
|
105
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UNDEF } from '../util/Utils.js';
|
|
2
2
|
import { Log, misuse } from '../util/Dbg.js';
|
|
3
3
|
import { Kind, Reentrance } from '../Options.js';
|
|
4
|
-
import { ObjectSnapshot, ObjectHandle,
|
|
4
|
+
import { ObjectSnapshot, ObjectHandle, MvccValue, Meta } from './Data.js';
|
|
5
5
|
import { Changeset, Dump, EMPTY_SNAPSHOT } from './Changeset.js';
|
|
6
6
|
export class MvccObject {
|
|
7
7
|
constructor(observable) {
|
|
@@ -72,7 +72,7 @@ export class Mvcc {
|
|
|
72
72
|
const cs = Changeset.current();
|
|
73
73
|
const os = cs.getObjectSnapshot(h, m);
|
|
74
74
|
result = os.data[m];
|
|
75
|
-
if (result instanceof
|
|
75
|
+
if (result instanceof MvccValue && !result.isOperation) {
|
|
76
76
|
if (this.isObservable)
|
|
77
77
|
Changeset.markUsed(result, os, m, h, Kind.Plain, false);
|
|
78
78
|
result = result.content;
|
|
@@ -92,7 +92,7 @@ export class Mvcc {
|
|
|
92
92
|
if (curr === undefined || curr.content !== value || Mvcc.sensitivity) {
|
|
93
93
|
const existing = curr === null || curr === void 0 ? void 0 : curr.content;
|
|
94
94
|
if (os.former.snapshot.data[m] === curr) {
|
|
95
|
-
curr = os.data[m] = new
|
|
95
|
+
curr = os.data[m] = new MvccValue(value);
|
|
96
96
|
Changeset.markEdited(existing, value, true, os, m, h);
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
@@ -130,14 +130,14 @@ export class Mvcc {
|
|
|
130
130
|
const result = [];
|
|
131
131
|
for (const m of Object.getOwnPropertyNames(os.data)) {
|
|
132
132
|
const value = os.data[m];
|
|
133
|
-
if (!(value instanceof
|
|
133
|
+
if (!(value instanceof MvccValue) || !value.isOperation)
|
|
134
134
|
result.push(m);
|
|
135
135
|
}
|
|
136
136
|
return result;
|
|
137
137
|
}
|
|
138
138
|
static decorateData(isObservable, proto, member) {
|
|
139
139
|
if (isObservable) {
|
|
140
|
-
Meta.acquire(proto, Meta.Initial)[member] = new
|
|
140
|
+
Meta.acquire(proto, Meta.Initial)[member] = new MvccValue(undefined);
|
|
141
141
|
const get = function () {
|
|
142
142
|
const h = Mvcc.acquireHandle(this);
|
|
143
143
|
return Mvcc.observable.get(h, member, this);
|
|
@@ -196,7 +196,7 @@ export class Mvcc {
|
|
|
196
196
|
h = new ObjectHandle(obj, obj, Mvcc.observable, os, obj.constructor.name);
|
|
197
197
|
Meta.set(os.data, Meta.Handle, h);
|
|
198
198
|
Meta.set(obj, Meta.Handle, h);
|
|
199
|
-
Meta.set(os.data, Meta.Revision, new
|
|
199
|
+
Meta.set(os.data, Meta.Revision, new MvccValue(1));
|
|
200
200
|
}
|
|
201
201
|
return h;
|
|
202
202
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { F } from '../util/Utils.js';
|
|
2
2
|
import { MemberOptions } from '../Options.js';
|
|
3
|
-
import {
|
|
4
|
-
import { MemberName, ObjectHandle,
|
|
3
|
+
import { AbstractReaction } from '../Reaction.js';
|
|
4
|
+
import { MemberName, ObjectHandle, MvccValue, Observer, Subscription, AbstractChangeset } from './Data.js';
|
|
5
5
|
import { Transaction } from './Transaction.js';
|
|
6
6
|
import { OptionsImpl } from './Mvcc.js';
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class ReactionImpl implements AbstractReaction<any> {
|
|
8
8
|
readonly objectHandle: ObjectHandle;
|
|
9
9
|
readonly memberName: MemberName;
|
|
10
10
|
configure(options: Partial<MemberOptions>): MemberOptions;
|
|
@@ -18,10 +18,10 @@ export declare class OperationController extends Controller<any> {
|
|
|
18
18
|
markObsolete(): void;
|
|
19
19
|
pullLastResult(args?: any[]): any;
|
|
20
20
|
constructor(h: ObjectHandle, m: MemberName);
|
|
21
|
-
|
|
22
|
-
static getControllerOf(method: F<any>):
|
|
23
|
-
static configureImpl(self:
|
|
24
|
-
static
|
|
21
|
+
reuseOrRelaunch(weak: boolean, args: any[] | undefined): Launch;
|
|
22
|
+
static getControllerOf(method: F<any>): AbstractReaction<any>;
|
|
23
|
+
static configureImpl(self: ReactionImpl | undefined, options: Partial<MemberOptions>): MemberOptions;
|
|
24
|
+
static proceedWithinGivenLaunch<T>(launch: Launch | undefined, func: F<T>, ...args: any[]): T;
|
|
25
25
|
static why(): string;
|
|
26
26
|
static briefWhy(): string;
|
|
27
27
|
static dependencies(): string[];
|
|
@@ -29,18 +29,18 @@ export declare class OperationController extends Controller<any> {
|
|
|
29
29
|
private use;
|
|
30
30
|
private edit;
|
|
31
31
|
private acquireFromSnapshot;
|
|
32
|
-
private
|
|
32
|
+
private relaunch;
|
|
33
33
|
private static markObsolete;
|
|
34
34
|
}
|
|
35
|
-
declare class
|
|
36
|
-
static current?:
|
|
35
|
+
declare class Launch extends MvccValue implements Observer {
|
|
36
|
+
static current?: Launch;
|
|
37
37
|
static queuedReactiveFunctions: Array<Observer>;
|
|
38
|
-
static deferredReactiveFunctions: Array<
|
|
38
|
+
static deferredReactiveFunctions: Array<Launch>;
|
|
39
39
|
readonly margin: number;
|
|
40
40
|
readonly transaction: Transaction;
|
|
41
|
-
readonly
|
|
41
|
+
readonly reaction: ReactionImpl;
|
|
42
42
|
readonly changeset: AbstractChangeset;
|
|
43
|
-
observables: Map<
|
|
43
|
+
observables: Map<MvccValue, Subscription> | undefined;
|
|
44
44
|
options: OptionsImpl;
|
|
45
45
|
cause: string | undefined;
|
|
46
46
|
args: any[];
|
|
@@ -49,8 +49,8 @@ declare class Operation extends ObservableValue implements Observer {
|
|
|
49
49
|
started: number;
|
|
50
50
|
obsoleteDueTo: string | undefined;
|
|
51
51
|
obsoleteSince: number;
|
|
52
|
-
successor:
|
|
53
|
-
constructor(
|
|
52
|
+
successor: Launch | undefined;
|
|
53
|
+
constructor(reaction: ReactionImpl, changeset: AbstractChangeset, former: Launch | OptionsImpl);
|
|
54
54
|
get isOperation(): boolean;
|
|
55
55
|
get originSnapshotId(): number;
|
|
56
56
|
hint(): string;
|
|
@@ -60,12 +60,12 @@ declare class Operation extends ObservableValue implements Observer {
|
|
|
60
60
|
briefWhy(): string;
|
|
61
61
|
dependencies(): string[];
|
|
62
62
|
wrap<T>(func: F<T>): F<T>;
|
|
63
|
-
|
|
64
|
-
markObsoleteDueTo(observable:
|
|
65
|
-
|
|
63
|
+
proceed(proxy: any, args: any[] | undefined): void;
|
|
64
|
+
markObsoleteDueTo(observable: MvccValue, m: MemberName, changeset: AbstractChangeset, h: ObjectHandle, outer: string, since: number, obsolete: Observer[]): void;
|
|
65
|
+
relaunchIfNotUpToDate(now: boolean, nothrow: boolean): void;
|
|
66
66
|
isNotUpToDate(): boolean;
|
|
67
|
-
reenterOver(head:
|
|
68
|
-
private static
|
|
67
|
+
reenterOver(head: Launch): this;
|
|
68
|
+
private static proceed;
|
|
69
69
|
private enter;
|
|
70
70
|
private leaveOrAsync;
|
|
71
71
|
private leave;
|
|
@@ -80,7 +80,7 @@ declare class Operation extends ObservableValue implements Observer {
|
|
|
80
80
|
private static revokeAllSubscriptions;
|
|
81
81
|
private static propagateMemberChangeThroughSubscriptions;
|
|
82
82
|
private static enqueueReactiveFunctionsToRun;
|
|
83
|
-
private static
|
|
83
|
+
private static runQueuedReactiveFunctions;
|
|
84
84
|
private unsubscribeFromAllObservables;
|
|
85
85
|
private subscribeTo;
|
|
86
86
|
private static canSubscribeTo;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Log, misuse } from '../util/Dbg.js';
|
|
2
2
|
import { Kind, Reentrance } from '../Options.js';
|
|
3
|
-
import {
|
|
4
|
-
import { ObjectHandle, ObservableValue, Meta } from './Data.js';
|
|
3
|
+
import { ObjectHandle, MvccValue, Meta } from './Data.js';
|
|
5
4
|
import { Changeset, Dump, EMPTY_SNAPSHOT, MAX_REVISION } from './Changeset.js';
|
|
6
5
|
import { Transaction } from './Transaction.js';
|
|
7
6
|
import { MonitorImpl } from './Monitor.js';
|
|
@@ -10,47 +9,46 @@ import { JournalImpl } from './Journal.js';
|
|
|
10
9
|
const BOOT_ARGS = [];
|
|
11
10
|
const BOOT_CAUSE = '<boot>';
|
|
12
11
|
const EMPTY_HANDLE = new ObjectHandle(undefined, undefined, Mvcc.observable, EMPTY_SNAPSHOT, '<boot>');
|
|
13
|
-
export class
|
|
14
|
-
configure(options) { return
|
|
15
|
-
get options() { return this.peek(undefined).
|
|
16
|
-
get unobservable() { return this.peek(undefined).
|
|
17
|
-
get args() { return this.use().
|
|
18
|
-
get result() { return this.
|
|
19
|
-
get error() { return this.use().
|
|
12
|
+
export class ReactionImpl {
|
|
13
|
+
configure(options) { return ReactionImpl.configureImpl(this, options); }
|
|
14
|
+
get options() { return this.peek(undefined).launch.options; }
|
|
15
|
+
get unobservable() { return this.peek(undefined).launch.content; }
|
|
16
|
+
get args() { return this.use().launch.args; }
|
|
17
|
+
get result() { return this.reuseOrRelaunch(true, undefined).content; }
|
|
18
|
+
get error() { return this.use().launch.error; }
|
|
20
19
|
get stamp() { return this.use().snapshot.changeset.timestamp; }
|
|
21
20
|
get isUpToDate() { return this.use().isUpToDate; }
|
|
22
|
-
markObsolete() { Transaction.run({ hint: Log.isOn ? `markObsolete(${Dump.obj(this.objectHandle, this.memberName)})` : 'markObsolete()' },
|
|
23
|
-
pullLastResult(args) { return this.
|
|
21
|
+
markObsolete() { Transaction.run({ hint: Log.isOn ? `markObsolete(${Dump.obj(this.objectHandle, this.memberName)})` : 'markObsolete()' }, ReactionImpl.markObsolete, this); }
|
|
22
|
+
pullLastResult(args) { return this.reuseOrRelaunch(true, args).content; }
|
|
24
23
|
constructor(h, m) {
|
|
25
|
-
super();
|
|
26
24
|
this.objectHandle = h;
|
|
27
25
|
this.memberName = m;
|
|
28
26
|
}
|
|
29
|
-
|
|
27
|
+
reuseOrRelaunch(weak, args) {
|
|
30
28
|
var _a;
|
|
31
|
-
let
|
|
32
|
-
const ctx =
|
|
33
|
-
const
|
|
34
|
-
const opts =
|
|
35
|
-
if (!
|
|
36
|
-
&& (!weak ||
|
|
37
|
-
|
|
38
|
-
const outerOpts = (_a =
|
|
29
|
+
let ror = this.peek(args);
|
|
30
|
+
const ctx = ror.changeset;
|
|
31
|
+
const launch = ror.launch;
|
|
32
|
+
const opts = launch.options;
|
|
33
|
+
if (!ror.isUpToDate && !ror.snapshot.disposed
|
|
34
|
+
&& (!weak || launch.cause === BOOT_CAUSE || !launch.successor ||
|
|
35
|
+
launch.successor.transaction.isFinished)) {
|
|
36
|
+
const outerOpts = (_a = Launch.current) === null || _a === void 0 ? void 0 : _a.options;
|
|
39
37
|
const separation = weak || opts.separation !== false || opts.kind === Kind.Reactive ||
|
|
40
38
|
(opts.kind === Kind.Transactional && outerOpts && (outerOpts.noSideEffects || outerOpts.kind === Kind.Cached)) ||
|
|
41
|
-
(opts.kind === Kind.Cached && (
|
|
42
|
-
|
|
39
|
+
(opts.kind === Kind.Cached && (ror.snapshot.changeset.sealed ||
|
|
40
|
+
ror.snapshot.former.snapshot !== EMPTY_SNAPSHOT));
|
|
43
41
|
const token = opts.noSideEffects ? this : undefined;
|
|
44
|
-
const
|
|
45
|
-
const ctx2 =
|
|
42
|
+
const ror2 = this.relaunch(ror, separation, opts, token, args);
|
|
43
|
+
const ctx2 = ror2.launch.changeset;
|
|
46
44
|
if (!weak || ctx === ctx2 || (ctx2.sealed && ctx.timestamp >= ctx2.timestamp))
|
|
47
|
-
|
|
45
|
+
ror = ror2;
|
|
48
46
|
}
|
|
49
47
|
else if (Log.isOn && Log.opt.operation && (opts.logging === undefined ||
|
|
50
48
|
opts.logging.operation === undefined || opts.logging.operation === true))
|
|
51
|
-
Log.write(Transaction.current.isFinished ? '' : '║', ' (=)', `${Dump.snapshot2(
|
|
52
|
-
const t =
|
|
53
|
-
Changeset.markUsed(t,
|
|
49
|
+
Log.write(Transaction.current.isFinished ? '' : '║', ' (=)', `${Dump.snapshot2(ror.launch.reaction.objectHandle, ror.changeset, this.memberName)} result is reused from T${ror.launch.transaction.id}[${ror.launch.transaction.hint}]`);
|
|
50
|
+
const t = ror.launch;
|
|
51
|
+
Changeset.markUsed(t, ror.snapshot, this.memberName, this.objectHandle, t.options.kind, weak);
|
|
54
52
|
return t;
|
|
55
53
|
}
|
|
56
54
|
static getControllerOf(method) {
|
|
@@ -60,154 +58,154 @@ export class OperationController extends Controller {
|
|
|
60
58
|
return ctl;
|
|
61
59
|
}
|
|
62
60
|
static configureImpl(self, options) {
|
|
63
|
-
let
|
|
61
|
+
let launch;
|
|
64
62
|
if (self)
|
|
65
|
-
|
|
63
|
+
launch = self.edit().launch;
|
|
66
64
|
else
|
|
67
|
-
|
|
68
|
-
if (!
|
|
65
|
+
launch = Launch.current;
|
|
66
|
+
if (!launch)
|
|
69
67
|
throw misuse('reactronic decorator is only applicable to methods');
|
|
70
|
-
|
|
68
|
+
launch.options = new OptionsImpl(launch.options.getter, launch.options.setter, launch.options, options, false);
|
|
71
69
|
if (Log.isOn && Log.opt.write)
|
|
72
|
-
Log.write('║', ' =', `${
|
|
73
|
-
return
|
|
70
|
+
Log.write('║', ' =', `${launch.hint()}.options are changed`);
|
|
71
|
+
return launch.options;
|
|
74
72
|
}
|
|
75
|
-
static
|
|
73
|
+
static proceedWithinGivenLaunch(launch, func, ...args) {
|
|
76
74
|
let result = undefined;
|
|
77
|
-
const outer =
|
|
75
|
+
const outer = Launch.current;
|
|
78
76
|
try {
|
|
79
|
-
|
|
77
|
+
Launch.current = launch;
|
|
80
78
|
result = func(...args);
|
|
81
79
|
}
|
|
82
80
|
catch (e) {
|
|
83
|
-
if (
|
|
84
|
-
|
|
81
|
+
if (launch)
|
|
82
|
+
launch.error = e;
|
|
85
83
|
throw e;
|
|
86
84
|
}
|
|
87
85
|
finally {
|
|
88
|
-
|
|
86
|
+
Launch.current = outer;
|
|
89
87
|
}
|
|
90
88
|
return result;
|
|
91
89
|
}
|
|
92
90
|
static why() {
|
|
93
91
|
var _a, _b;
|
|
94
|
-
return (_b = (_a =
|
|
92
|
+
return (_b = (_a = Launch.current) === null || _a === void 0 ? void 0 : _a.why()) !== null && _b !== void 0 ? _b : BOOT_CAUSE;
|
|
95
93
|
}
|
|
96
94
|
static briefWhy() {
|
|
97
95
|
var _a, _b;
|
|
98
|
-
return (_b = (_a =
|
|
96
|
+
return (_b = (_a = Launch.current) === null || _a === void 0 ? void 0 : _a.briefWhy()) !== null && _b !== void 0 ? _b : BOOT_CAUSE;
|
|
99
97
|
}
|
|
100
98
|
static dependencies() {
|
|
101
|
-
const
|
|
102
|
-
return
|
|
99
|
+
const l = Launch.current;
|
|
100
|
+
return l ? l.dependencies() : ['Rx.dependencies should be called from inside of reactive method'];
|
|
103
101
|
}
|
|
104
102
|
peek(args) {
|
|
105
103
|
const ctx = Changeset.current();
|
|
106
104
|
const os = ctx.lookupObjectSnapshot(this.objectHandle, this.memberName);
|
|
107
|
-
const
|
|
108
|
-
const isValid =
|
|
109
|
-
(ctx ===
|
|
110
|
-
(!
|
|
111
|
-
|
|
112
|
-
return {
|
|
105
|
+
const launch = this.acquireFromSnapshot(os, args);
|
|
106
|
+
const isValid = launch.options.kind !== Kind.Transactional && launch.cause !== BOOT_CAUSE &&
|
|
107
|
+
(ctx === launch.changeset || ctx.timestamp < launch.obsoleteSince) &&
|
|
108
|
+
(!launch.options.triggeringArgs || args === undefined ||
|
|
109
|
+
launch.args.length === args.length && launch.args.every((t, i) => t === args[i])) || os.disposed;
|
|
110
|
+
return { launch, isUpToDate: isValid, changeset: ctx, snapshot: os };
|
|
113
111
|
}
|
|
114
112
|
use() {
|
|
115
|
-
const
|
|
116
|
-
Changeset.markUsed(
|
|
117
|
-
return
|
|
113
|
+
const ror = this.peek(undefined);
|
|
114
|
+
Changeset.markUsed(ror.launch, ror.snapshot, this.memberName, this.objectHandle, ror.launch.options.kind, true);
|
|
115
|
+
return ror;
|
|
118
116
|
}
|
|
119
117
|
edit() {
|
|
120
118
|
const h = this.objectHandle;
|
|
121
119
|
const m = this.memberName;
|
|
122
120
|
const ctx = Changeset.edit();
|
|
123
121
|
const os = ctx.getEditableObjectSnapshot(h, m, Meta.Handle, this);
|
|
124
|
-
let
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
os.data[m] =
|
|
122
|
+
let launch = this.acquireFromSnapshot(os, undefined);
|
|
123
|
+
if (launch.changeset !== os.changeset) {
|
|
124
|
+
const relaunch = new Launch(this, os.changeset, launch);
|
|
125
|
+
os.data[m] = relaunch.reenterOver(launch);
|
|
128
126
|
ctx.bumpBy(os.former.snapshot.changeset.timestamp);
|
|
129
|
-
Changeset.markEdited(
|
|
130
|
-
|
|
127
|
+
Changeset.markEdited(launch, relaunch, true, os, m, h);
|
|
128
|
+
launch = relaunch;
|
|
131
129
|
}
|
|
132
|
-
return {
|
|
130
|
+
return { launch, isUpToDate: true, changeset: ctx, snapshot: os };
|
|
133
131
|
}
|
|
134
132
|
acquireFromSnapshot(os, args) {
|
|
135
133
|
const m = this.memberName;
|
|
136
|
-
let
|
|
137
|
-
if (
|
|
134
|
+
let launch = os.data[m];
|
|
135
|
+
if (launch.reaction !== this) {
|
|
138
136
|
if (os.changeset !== EMPTY_SNAPSHOT.changeset) {
|
|
139
137
|
const hint = Log.isOn ? `${Dump.obj(this.objectHandle, m)}/init` : 'MethodController/init';
|
|
140
138
|
const separation = os.changeset.sealed || os.former.snapshot !== EMPTY_SNAPSHOT;
|
|
141
|
-
|
|
139
|
+
launch = Transaction.run({ hint, separation, token: this }, () => {
|
|
142
140
|
const h = this.objectHandle;
|
|
143
|
-
let
|
|
144
|
-
let
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
const t = new
|
|
141
|
+
let r = Changeset.current().getObjectSnapshot(h, m);
|
|
142
|
+
let relaunch = r.data[m];
|
|
143
|
+
if (relaunch.reaction !== this) {
|
|
144
|
+
r = Changeset.edit().getEditableObjectSnapshot(h, m, Meta.Handle, this);
|
|
145
|
+
const t = new Launch(this, r.changeset, relaunch);
|
|
148
146
|
if (args)
|
|
149
147
|
t.args = args;
|
|
150
148
|
t.cause = BOOT_CAUSE;
|
|
151
|
-
|
|
152
|
-
Changeset.markEdited(
|
|
153
|
-
|
|
149
|
+
r.data[m] = t;
|
|
150
|
+
Changeset.markEdited(relaunch, t, true, r, m, h);
|
|
151
|
+
relaunch = t;
|
|
154
152
|
}
|
|
155
|
-
return
|
|
153
|
+
return relaunch;
|
|
156
154
|
});
|
|
157
155
|
}
|
|
158
156
|
else {
|
|
159
|
-
const
|
|
157
|
+
const initialLaunch = new Launch(this, os.changeset, launch);
|
|
160
158
|
if (args)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
os.data[m] =
|
|
164
|
-
|
|
159
|
+
initialLaunch.args = args;
|
|
160
|
+
initialLaunch.cause = BOOT_CAUSE;
|
|
161
|
+
os.data[m] = initialLaunch;
|
|
162
|
+
launch = initialLaunch;
|
|
165
163
|
if (Log.isOn && Log.opt.write)
|
|
166
164
|
Log.write('║', ' ++', `${Dump.obj(this.objectHandle, m)} is initialized (revision ${os.revision})`);
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
|
-
return
|
|
167
|
+
return launch;
|
|
170
168
|
}
|
|
171
|
-
|
|
169
|
+
relaunch(existing, separation, options, token, args) {
|
|
172
170
|
const hint = Log.isOn ? `${Dump.obj(this.objectHandle, this.memberName)}${args && args.length > 0 && (typeof args[0] === 'number' || typeof args[0] === 'string') ? ` - ${args[0]}` : ''}` : `${Dump.obj(this.objectHandle, this.memberName)}`;
|
|
173
|
-
let
|
|
171
|
+
let ror = existing;
|
|
174
172
|
const opts = { hint, separation, journal: options.journal, logging: options.logging, token };
|
|
175
173
|
const result = Transaction.run(opts, (argsx) => {
|
|
176
|
-
if (!
|
|
177
|
-
|
|
174
|
+
if (!ror.launch.transaction.isCanceled) {
|
|
175
|
+
ror = this.edit();
|
|
178
176
|
if (Log.isOn && Log.opt.operation)
|
|
179
|
-
Log.write('║', ' o', `${
|
|
180
|
-
|
|
177
|
+
Log.write('║', ' o', `${ror.launch.why()}`);
|
|
178
|
+
ror.launch.proceed(this.objectHandle.proxy, argsx);
|
|
181
179
|
}
|
|
182
180
|
else {
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
|
|
181
|
+
ror = this.peek(argsx);
|
|
182
|
+
if (ror.launch.options.kind === Kind.Transactional || !ror.isUpToDate) {
|
|
183
|
+
ror = this.edit();
|
|
186
184
|
if (Log.isOn && Log.opt.operation)
|
|
187
|
-
Log.write('║', ' o', `${
|
|
188
|
-
|
|
185
|
+
Log.write('║', ' o', `${ror.launch.why()}`);
|
|
186
|
+
ror.launch.proceed(this.objectHandle.proxy, argsx);
|
|
189
187
|
}
|
|
190
188
|
}
|
|
191
|
-
return
|
|
189
|
+
return ror.launch.result;
|
|
192
190
|
}, args);
|
|
193
|
-
|
|
194
|
-
return
|
|
191
|
+
ror.launch.result = result;
|
|
192
|
+
return ror;
|
|
195
193
|
}
|
|
196
194
|
static markObsolete(self) {
|
|
197
|
-
const
|
|
198
|
-
const ctx =
|
|
199
|
-
|
|
195
|
+
const ror = self.peek(undefined);
|
|
196
|
+
const ctx = ror.changeset;
|
|
197
|
+
ror.launch.markObsoleteDueTo(ror.launch, self.memberName, EMPTY_SNAPSHOT.changeset, EMPTY_HANDLE, BOOT_CAUSE, ctx.timestamp, ctx.obsolete);
|
|
200
198
|
}
|
|
201
199
|
}
|
|
202
|
-
class
|
|
203
|
-
constructor(
|
|
200
|
+
class Launch extends MvccValue {
|
|
201
|
+
constructor(reaction, changeset, former) {
|
|
204
202
|
super(undefined);
|
|
205
|
-
this.margin =
|
|
203
|
+
this.margin = Launch.current ? Launch.current.margin + 1 : 1;
|
|
206
204
|
this.transaction = Transaction.current;
|
|
207
|
-
this.
|
|
205
|
+
this.reaction = reaction;
|
|
208
206
|
this.changeset = changeset;
|
|
209
207
|
this.observables = new Map();
|
|
210
|
-
if (former instanceof
|
|
208
|
+
if (former instanceof Launch) {
|
|
211
209
|
this.options = former.options;
|
|
212
210
|
this.args = former.args;
|
|
213
211
|
this.cause = former.obsoleteDueTo;
|
|
@@ -224,7 +222,7 @@ class Operation extends ObservableValue {
|
|
|
224
222
|
}
|
|
225
223
|
get isOperation() { return true; }
|
|
226
224
|
get originSnapshotId() { return this.changeset.id; }
|
|
227
|
-
hint() { return `${Dump.snapshot2(this.
|
|
225
|
+
hint() { return `${Dump.snapshot2(this.reaction.objectHandle, this.changeset, this.reaction.memberName)}`; }
|
|
228
226
|
get order() { return this.options.order; }
|
|
229
227
|
get ['#this#']() {
|
|
230
228
|
return `Operation: ${this.why()}`;
|
|
@@ -233,7 +231,7 @@ class Operation extends ObservableValue {
|
|
|
233
231
|
let cause;
|
|
234
232
|
if (this.cause)
|
|
235
233
|
cause = ` ◀◀ ${this.cause}`;
|
|
236
|
-
else if (this.
|
|
234
|
+
else if (this.reaction.options.kind === Kind.Transactional)
|
|
237
235
|
cause = ' ◀◀ operation';
|
|
238
236
|
else
|
|
239
237
|
cause = ` ◀◀ T${this.changeset.id}[${this.changeset.hint}]`;
|
|
@@ -250,7 +248,7 @@ class Operation extends ObservableValue {
|
|
|
250
248
|
if (Log.isOn && Log.opt.step && this.result)
|
|
251
249
|
Log.writeAs({ margin2: this.margin }, '║', '‾\\', `${this.hint()} - step in `, 0, ' │');
|
|
252
250
|
const started = Date.now();
|
|
253
|
-
const result =
|
|
251
|
+
const result = ReactionImpl.proceedWithinGivenLaunch(this, func, ...args);
|
|
254
252
|
const ms = Date.now() - started;
|
|
255
253
|
if (Log.isOn && Log.opt.step && this.result)
|
|
256
254
|
Log.writeAs({ margin2: this.margin }, '║', '_/', `${this.hint()} - step out `, 0, this.started > 0 ? ' │' : '');
|
|
@@ -260,16 +258,16 @@ class Operation extends ObservableValue {
|
|
|
260
258
|
};
|
|
261
259
|
return wrappedForOperation;
|
|
262
260
|
}
|
|
263
|
-
|
|
261
|
+
proceed(proxy, args) {
|
|
264
262
|
if (args)
|
|
265
263
|
this.args = args;
|
|
266
264
|
this.obsoleteSince = MAX_REVISION;
|
|
267
265
|
if (!this.error)
|
|
268
|
-
|
|
266
|
+
ReactionImpl.proceedWithinGivenLaunch(this, Launch.proceed, this, proxy);
|
|
269
267
|
else
|
|
270
268
|
this.result = Promise.reject(this.error);
|
|
271
269
|
}
|
|
272
|
-
markObsoleteDueTo(observable, m, changeset, h, outer, since,
|
|
270
|
+
markObsoleteDueTo(observable, m, changeset, h, outer, since, obsolete) {
|
|
273
271
|
var _a, _b, _c;
|
|
274
272
|
if (this.observables !== undefined) {
|
|
275
273
|
const skip = !observable.isOperation &&
|
|
@@ -285,9 +283,9 @@ class Operation extends ObservableValue {
|
|
|
285
283
|
: `${this.hint()} is obsolete due to ${Dump.snapshot2(h, changeset, m)} since s${since}${isReactive ? ` and will run automatically (order ${this.options.order})` : ''}`);
|
|
286
284
|
this.unsubscribeFromAllObservables();
|
|
287
285
|
if (isReactive)
|
|
288
|
-
|
|
286
|
+
obsolete.push(this);
|
|
289
287
|
else
|
|
290
|
-
(_b = this.observers) === null || _b === void 0 ? void 0 : _b.forEach(s => s.markObsoleteDueTo(this, this.
|
|
288
|
+
(_b = this.observers) === null || _b === void 0 ? void 0 : _b.forEach(s => s.markObsoleteDueTo(this, this.reaction.memberName, this.changeset, this.reaction.objectHandle, why, since, obsolete));
|
|
291
289
|
const tran = this.transaction;
|
|
292
290
|
if (tran.changeset === changeset) {
|
|
293
291
|
}
|
|
@@ -298,18 +296,18 @@ class Operation extends ObservableValue {
|
|
|
298
296
|
Log.write(' ', 'x', `${this.hint()} is not obsolete due to its own change to ${Dump.snapshot2(h, changeset, m)}`);
|
|
299
297
|
}
|
|
300
298
|
}
|
|
301
|
-
|
|
299
|
+
relaunchIfNotUpToDate(now, nothrow) {
|
|
302
300
|
const t = this.options.throttling;
|
|
303
301
|
const interval = Date.now() + this.started;
|
|
304
302
|
const hold = t ? t - interval : 0;
|
|
305
303
|
if (now || hold < 0) {
|
|
306
304
|
if (this.isNotUpToDate()) {
|
|
307
305
|
try {
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
|
|
311
|
-
if (
|
|
312
|
-
misuse(`reactive function ${
|
|
306
|
+
const launch = this.reaction.reuseOrRelaunch(false, undefined);
|
|
307
|
+
if (launch.result instanceof Promise)
|
|
308
|
+
launch.result.catch(error => {
|
|
309
|
+
if (launch.options.kind === Kind.Reactive)
|
|
310
|
+
misuse(`reactive function ${launch.hint()} failed and will not run anymore: ${error}`, error);
|
|
313
311
|
});
|
|
314
312
|
}
|
|
315
313
|
catch (e) {
|
|
@@ -322,7 +320,7 @@ class Operation extends ObservableValue {
|
|
|
322
320
|
}
|
|
323
321
|
else if (t < Number.MAX_SAFE_INTEGER) {
|
|
324
322
|
if (hold > 0)
|
|
325
|
-
setTimeout(() => this.
|
|
323
|
+
setTimeout(() => this.relaunchIfNotUpToDate(true, true), hold);
|
|
326
324
|
else
|
|
327
325
|
this.addToDeferredReactiveFunctions();
|
|
328
326
|
}
|
|
@@ -366,20 +364,20 @@ class Operation extends ObservableValue {
|
|
|
366
364
|
this.error = error;
|
|
367
365
|
return this;
|
|
368
366
|
}
|
|
369
|
-
static
|
|
370
|
-
|
|
367
|
+
static proceed(launch, proxy) {
|
|
368
|
+
launch.enter();
|
|
371
369
|
try {
|
|
372
|
-
|
|
370
|
+
launch.result = launch.options.getter.call(proxy, ...launch.args);
|
|
373
371
|
}
|
|
374
372
|
finally {
|
|
375
|
-
|
|
373
|
+
launch.leaveOrAsync();
|
|
376
374
|
}
|
|
377
375
|
}
|
|
378
376
|
enter() {
|
|
379
377
|
if (this.options.monitor)
|
|
380
378
|
this.monitorEnter(this.options.monitor);
|
|
381
379
|
if (Log.isOn && Log.opt.operation)
|
|
382
|
-
Log.write('║', '‾\\', `${this.hint()} - enter`, undefined, ` [ ${Dump.obj(this.
|
|
380
|
+
Log.write('║', '‾\\', `${this.hint()} - enter`, undefined, ` [ ${Dump.obj(this.reaction.objectHandle, this.reaction.memberName)} ]`);
|
|
383
381
|
this.started = Date.now();
|
|
384
382
|
}
|
|
385
383
|
leaveOrAsync() {
|
|
@@ -422,7 +420,7 @@ class Operation extends ObservableValue {
|
|
|
422
420
|
separation: 'isolated',
|
|
423
421
|
logging: Log.isOn && Log.opt.monitor ? undefined : Log.global
|
|
424
422
|
};
|
|
425
|
-
|
|
423
|
+
ReactionImpl.proceedWithinGivenLaunch(undefined, Transaction.run, options, MonitorImpl.enter, mon, this.transaction);
|
|
426
424
|
}
|
|
427
425
|
monitorLeave(mon) {
|
|
428
426
|
Transaction.outside(() => {
|
|
@@ -432,33 +430,33 @@ class Operation extends ObservableValue {
|
|
|
432
430
|
separation: 'isolated',
|
|
433
431
|
logging: Log.isOn && Log.opt.monitor ? undefined : Log.DefaultLevel
|
|
434
432
|
};
|
|
435
|
-
|
|
433
|
+
ReactionImpl.proceedWithinGivenLaunch(undefined, Transaction.run, options, MonitorImpl.leave, mon, this.transaction);
|
|
436
434
|
};
|
|
437
435
|
this.transaction.whenFinished().then(leave, leave);
|
|
438
436
|
});
|
|
439
437
|
}
|
|
440
438
|
addToDeferredReactiveFunctions() {
|
|
441
|
-
|
|
442
|
-
if (
|
|
443
|
-
setTimeout(
|
|
439
|
+
Launch.deferredReactiveFunctions.push(this);
|
|
440
|
+
if (Launch.deferredReactiveFunctions.length === 1)
|
|
441
|
+
setTimeout(Launch.processDeferredReactiveFunctions, 0);
|
|
444
442
|
}
|
|
445
443
|
static processDeferredReactiveFunctions() {
|
|
446
|
-
const deferred =
|
|
447
|
-
|
|
444
|
+
const deferred = Launch.deferredReactiveFunctions;
|
|
445
|
+
Launch.deferredReactiveFunctions = [];
|
|
448
446
|
for (const x of deferred)
|
|
449
|
-
x.
|
|
447
|
+
x.relaunchIfNotUpToDate(true, true);
|
|
450
448
|
}
|
|
451
449
|
static markUsed(observable, os, m, h, kind, weak) {
|
|
452
450
|
if (kind !== Kind.Transactional) {
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
|
|
451
|
+
const launch = Launch.current;
|
|
452
|
+
if (launch && launch.options.kind !== Kind.Transactional &&
|
|
453
|
+
launch.transaction === Transaction.current && m !== Meta.Handle) {
|
|
456
454
|
const ctx = Changeset.current();
|
|
457
455
|
if (ctx !== os.changeset)
|
|
458
456
|
ctx.bumpBy(os.changeset.timestamp);
|
|
459
457
|
const t = weak ? -1 : ctx.timestamp;
|
|
460
|
-
if (!
|
|
461
|
-
|
|
458
|
+
if (!launch.subscribeTo(observable, os, m, h, t))
|
|
459
|
+
launch.markObsoleteDueTo(observable, m, h.head.changeset, h, BOOT_CAUSE, ctx.timestamp, ctx.obsolete);
|
|
462
460
|
}
|
|
463
461
|
}
|
|
464
462
|
}
|
|
@@ -470,38 +468,38 @@ class Operation extends ObservableValue {
|
|
|
470
468
|
static isConflicting(oldValue, newValue) {
|
|
471
469
|
let result = oldValue !== newValue;
|
|
472
470
|
if (result)
|
|
473
|
-
result = oldValue instanceof
|
|
471
|
+
result = oldValue instanceof Launch && oldValue.cause !== BOOT_CAUSE;
|
|
474
472
|
return result;
|
|
475
473
|
}
|
|
476
474
|
static propagateAllChangesThroughSubscriptions(changeset) {
|
|
477
475
|
var _a;
|
|
478
476
|
const since = changeset.timestamp;
|
|
479
|
-
const
|
|
477
|
+
const obsolete = changeset.obsolete;
|
|
480
478
|
changeset.items.forEach((os, h) => {
|
|
481
|
-
|
|
479
|
+
Launch.propagateMemberChangeThroughSubscriptions(false, since, os, Meta.Revision, h, obsolete);
|
|
482
480
|
if (!os.disposed)
|
|
483
|
-
os.changes.forEach((o, m) =>
|
|
481
|
+
os.changes.forEach((o, m) => Launch.propagateMemberChangeThroughSubscriptions(false, since, os, m, h, obsolete));
|
|
484
482
|
else
|
|
485
483
|
for (const m in os.former.snapshot.data)
|
|
486
|
-
|
|
484
|
+
Launch.propagateMemberChangeThroughSubscriptions(true, since, os, m, h, obsolete);
|
|
487
485
|
});
|
|
488
|
-
|
|
486
|
+
obsolete.sort(compareObserversByOrder);
|
|
489
487
|
(_a = changeset.options.journal) === null || _a === void 0 ? void 0 : _a.edited(JournalImpl.buildPatch(changeset.hint, changeset.items));
|
|
490
488
|
}
|
|
491
489
|
static revokeAllSubscriptions(changeset) {
|
|
492
490
|
changeset.items.forEach((os, h) => {
|
|
493
|
-
|
|
494
|
-
os.changes.forEach((o, m) =>
|
|
491
|
+
Launch.propagateMemberChangeThroughSubscriptions(true, changeset.timestamp, os, Meta.Revision, h, undefined);
|
|
492
|
+
os.changes.forEach((o, m) => Launch.propagateMemberChangeThroughSubscriptions(true, changeset.timestamp, os, m, h, undefined));
|
|
495
493
|
});
|
|
496
494
|
}
|
|
497
|
-
static propagateMemberChangeThroughSubscriptions(unsubscribe, timestamp, os, m, h,
|
|
495
|
+
static propagateMemberChangeThroughSubscriptions(unsubscribe, timestamp, os, m, h, obsolete) {
|
|
498
496
|
var _a;
|
|
499
497
|
const curr = os.data[m];
|
|
500
|
-
if (
|
|
498
|
+
if (obsolete !== undefined) {
|
|
501
499
|
const former = os.former.snapshot.data[m];
|
|
502
|
-
if (former !== undefined && former instanceof
|
|
500
|
+
if (former !== undefined && former instanceof MvccValue) {
|
|
503
501
|
const why = `T${os.changeset.id}[${os.changeset.hint}]`;
|
|
504
|
-
if (former instanceof
|
|
502
|
+
if (former instanceof Launch) {
|
|
505
503
|
if ((former.obsoleteSince === MAX_REVISION || former.obsoleteSince <= 0)) {
|
|
506
504
|
former.obsoleteDueTo = why;
|
|
507
505
|
former.obsoleteSince = timestamp;
|
|
@@ -515,10 +513,10 @@ class Operation extends ObservableValue {
|
|
|
515
513
|
else
|
|
516
514
|
former.successor = undefined;
|
|
517
515
|
}
|
|
518
|
-
(_a = former.observers) === null || _a === void 0 ? void 0 : _a.forEach(s => s.markObsoleteDueTo(former, m, os.changeset, h, why, timestamp,
|
|
516
|
+
(_a = former.observers) === null || _a === void 0 ? void 0 : _a.forEach(s => s.markObsoleteDueTo(former, m, os.changeset, h, why, timestamp, obsolete));
|
|
519
517
|
}
|
|
520
518
|
}
|
|
521
|
-
if (curr instanceof
|
|
519
|
+
if (curr instanceof Launch) {
|
|
522
520
|
if (curr.changeset === os.changeset && curr.observables !== undefined) {
|
|
523
521
|
if (Mvcc.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
|
|
524
522
|
curr.observables.forEach((info, v) => {
|
|
@@ -530,26 +528,26 @@ class Operation extends ObservableValue {
|
|
|
530
528
|
curr.unsubscribeFromAllObservables();
|
|
531
529
|
}
|
|
532
530
|
}
|
|
533
|
-
else if (curr instanceof
|
|
531
|
+
else if (curr instanceof MvccValue && curr.observers) {
|
|
534
532
|
}
|
|
535
533
|
}
|
|
536
534
|
static enqueueReactiveFunctionsToRun(reactive) {
|
|
537
|
-
const queue =
|
|
535
|
+
const queue = Launch.queuedReactiveFunctions;
|
|
538
536
|
const isReactiveLoopRequired = queue.length === 0;
|
|
539
537
|
for (const r of reactive)
|
|
540
538
|
queue.push(r);
|
|
541
539
|
if (isReactiveLoopRequired)
|
|
542
|
-
|
|
540
|
+
ReactionImpl.proceedWithinGivenLaunch(undefined, Launch.runQueuedReactiveFunctions);
|
|
543
541
|
}
|
|
544
|
-
static
|
|
545
|
-
const queue =
|
|
542
|
+
static runQueuedReactiveFunctions() {
|
|
543
|
+
const queue = Launch.queuedReactiveFunctions;
|
|
546
544
|
let i = 0;
|
|
547
545
|
while (i < queue.length) {
|
|
548
546
|
const reactive = queue[i];
|
|
549
|
-
reactive.
|
|
547
|
+
reactive.relaunchIfNotUpToDate(false, true);
|
|
550
548
|
i++;
|
|
551
549
|
}
|
|
552
|
-
|
|
550
|
+
Launch.queuedReactiveFunctions = [];
|
|
553
551
|
}
|
|
554
552
|
unsubscribeFromAllObservables() {
|
|
555
553
|
var _a;
|
|
@@ -563,7 +561,7 @@ class Operation extends ObservableValue {
|
|
|
563
561
|
}
|
|
564
562
|
subscribeTo(observable, os, m, h, timestamp) {
|
|
565
563
|
var _a, _b, _c;
|
|
566
|
-
const ok =
|
|
564
|
+
const ok = Launch.canSubscribeTo(observable, os, m, h, timestamp);
|
|
567
565
|
if (ok) {
|
|
568
566
|
let times = 0;
|
|
569
567
|
if (Mvcc.repetitiveUsageWarningThreshold < Number.MAX_SAFE_INTEGER) {
|
|
@@ -592,71 +590,71 @@ class Operation extends ObservableValue {
|
|
|
592
590
|
const observableHead = h.head.data[m];
|
|
593
591
|
let result = observable === observableHead || (!os.changeset.sealed && os.former.snapshot.data[m] === observableHead);
|
|
594
592
|
if (result && timestamp !== -1)
|
|
595
|
-
result = !(observable instanceof
|
|
593
|
+
result = !(observable instanceof Launch && timestamp >= observable.obsoleteSince);
|
|
596
594
|
return result;
|
|
597
595
|
}
|
|
598
596
|
static createOperation(h, m, options) {
|
|
599
|
-
const
|
|
597
|
+
const rx = new ReactionImpl(h, m);
|
|
600
598
|
const operation = (...args) => {
|
|
601
|
-
return
|
|
599
|
+
return rx.reuseOrRelaunch(false, args).result;
|
|
602
600
|
};
|
|
603
|
-
Meta.set(operation, Meta.Controller,
|
|
601
|
+
Meta.set(operation, Meta.Controller, rx);
|
|
604
602
|
return operation;
|
|
605
603
|
}
|
|
606
604
|
static rememberOperationOptions(proto, m, getter, setter, enumerable, configurable, options, implicit) {
|
|
607
605
|
const initial = Meta.acquire(proto, Meta.Initial);
|
|
608
|
-
let
|
|
609
|
-
const
|
|
610
|
-
const opts =
|
|
611
|
-
initial[m] =
|
|
612
|
-
if (
|
|
606
|
+
let launch = initial[m];
|
|
607
|
+
const rx = launch ? launch.reaction : new ReactionImpl(EMPTY_HANDLE, m);
|
|
608
|
+
const opts = launch ? launch.options : OptionsImpl.INITIAL;
|
|
609
|
+
initial[m] = launch = new Launch(rx, EMPTY_SNAPSHOT.changeset, new OptionsImpl(getter, setter, opts, options, implicit));
|
|
610
|
+
if (launch.options.kind === Kind.Reactive && launch.options.throttling < Number.MAX_SAFE_INTEGER) {
|
|
613
611
|
const reactive = Meta.acquire(proto, Meta.Reactive);
|
|
614
|
-
reactive[m] =
|
|
612
|
+
reactive[m] = launch;
|
|
615
613
|
}
|
|
616
|
-
else if (
|
|
614
|
+
else if (launch.options.kind === Kind.Reactive && launch.options.throttling >= Number.MAX_SAFE_INTEGER) {
|
|
617
615
|
const reactive = Meta.getFrom(proto, Meta.Reactive);
|
|
618
616
|
delete reactive[m];
|
|
619
617
|
}
|
|
620
|
-
return
|
|
618
|
+
return launch.options;
|
|
621
619
|
}
|
|
622
620
|
static init() {
|
|
623
621
|
Object.freeze(BOOT_ARGS);
|
|
624
622
|
Log.getMergedLoggingOptions = getMergedLoggingOptions;
|
|
625
623
|
Dump.valueHint = valueHint;
|
|
626
|
-
Changeset.markUsed =
|
|
627
|
-
Changeset.markEdited =
|
|
628
|
-
Changeset.isConflicting =
|
|
629
|
-
Changeset.propagateAllChangesThroughSubscriptions =
|
|
630
|
-
Changeset.revokeAllSubscriptions =
|
|
631
|
-
Changeset.enqueueReactiveFunctionsToRun =
|
|
632
|
-
Mvcc.createOperation =
|
|
633
|
-
Mvcc.rememberOperationOptions =
|
|
624
|
+
Changeset.markUsed = Launch.markUsed;
|
|
625
|
+
Changeset.markEdited = Launch.markEdited;
|
|
626
|
+
Changeset.isConflicting = Launch.isConflicting;
|
|
627
|
+
Changeset.propagateAllChangesThroughSubscriptions = Launch.propagateAllChangesThroughSubscriptions;
|
|
628
|
+
Changeset.revokeAllSubscriptions = Launch.revokeAllSubscriptions;
|
|
629
|
+
Changeset.enqueueReactiveFunctionsToRun = Launch.enqueueReactiveFunctionsToRun;
|
|
630
|
+
Mvcc.createOperation = Launch.createOperation;
|
|
631
|
+
Mvcc.rememberOperationOptions = Launch.rememberOperationOptions;
|
|
634
632
|
Promise.prototype.then = reactronicHookedThen;
|
|
635
633
|
try {
|
|
636
634
|
Object.defineProperty(globalThis, 'rWhy', {
|
|
637
|
-
get:
|
|
635
|
+
get: ReactionImpl.why, configurable: false, enumerable: false,
|
|
638
636
|
});
|
|
639
637
|
Object.defineProperty(globalThis, 'rBriefWhy', {
|
|
640
|
-
get:
|
|
638
|
+
get: ReactionImpl.briefWhy, configurable: false, enumerable: false,
|
|
641
639
|
});
|
|
642
640
|
}
|
|
643
641
|
catch (e) {
|
|
644
642
|
}
|
|
645
643
|
try {
|
|
646
644
|
Object.defineProperty(global, 'rWhy', {
|
|
647
|
-
get:
|
|
645
|
+
get: ReactionImpl.why, configurable: false, enumerable: false,
|
|
648
646
|
});
|
|
649
647
|
Object.defineProperty(global, 'rBriefWhy', {
|
|
650
|
-
get:
|
|
648
|
+
get: ReactionImpl.briefWhy, configurable: false, enumerable: false,
|
|
651
649
|
});
|
|
652
650
|
}
|
|
653
651
|
catch (e) {
|
|
654
652
|
}
|
|
655
653
|
}
|
|
656
654
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
655
|
+
Launch.current = undefined;
|
|
656
|
+
Launch.queuedReactiveFunctions = [];
|
|
657
|
+
Launch.deferredReactiveFunctions = [];
|
|
660
658
|
function valueHint(value) {
|
|
661
659
|
let result = '';
|
|
662
660
|
if (Array.isArray(value))
|
|
@@ -665,8 +663,8 @@ function valueHint(value) {
|
|
|
665
663
|
result = `Set(${value.size})`;
|
|
666
664
|
else if (value instanceof Map)
|
|
667
665
|
result = `Map(${value.size})`;
|
|
668
|
-
else if (value instanceof
|
|
669
|
-
result = `#${value.
|
|
666
|
+
else if (value instanceof Launch)
|
|
667
|
+
result = `#${value.reaction.objectHandle.id}t${value.changeset.id}s${value.changeset.timestamp}${value.originSnapshotId !== undefined && value.originSnapshotId !== 0 ? `t${value.originSnapshotId}` : ''}`;
|
|
670
668
|
else if (value === Meta.Undefined)
|
|
671
669
|
result = 'undefined';
|
|
672
670
|
else if (typeof (value) === 'string')
|
|
@@ -681,8 +679,8 @@ function getMergedLoggingOptions(local) {
|
|
|
681
679
|
const t = Transaction.current;
|
|
682
680
|
let res = Log.merge(t.options.logging, t.id > 1 ? 31 + t.id % 6 : 37, t.id > 1 ? `T${t.id}` : `-${Changeset.idGen.toString().replace(/[0-9]/g, '-')}`, Log.global);
|
|
683
681
|
res = Log.merge({ margin1: t.margin }, undefined, undefined, res);
|
|
684
|
-
if (
|
|
685
|
-
res = Log.merge({ margin2:
|
|
682
|
+
if (Launch.current)
|
|
683
|
+
res = Log.merge({ margin2: Launch.current.margin }, undefined, undefined, res);
|
|
686
684
|
if (local)
|
|
687
685
|
res = Log.merge(local, undefined, undefined, res);
|
|
688
686
|
return res;
|
|
@@ -695,17 +693,17 @@ function reactronicHookedThen(resolve, reject) {
|
|
|
695
693
|
resolve = resolveReturn;
|
|
696
694
|
if (!reject)
|
|
697
695
|
reject = rejectRethrow;
|
|
698
|
-
const
|
|
699
|
-
if (
|
|
700
|
-
resolve =
|
|
701
|
-
reject =
|
|
696
|
+
const launch = Launch.current;
|
|
697
|
+
if (launch) {
|
|
698
|
+
resolve = launch.wrap(resolve);
|
|
699
|
+
reject = launch.wrap(reject);
|
|
702
700
|
}
|
|
703
701
|
resolve = tran.wrap(resolve, false);
|
|
704
702
|
reject = tran.wrap(reject, true);
|
|
705
703
|
}
|
|
706
704
|
return ORIGINAL_PROMISE_THEN.call(this, resolve, reject);
|
|
707
705
|
}
|
|
708
|
-
function
|
|
706
|
+
function compareObserversByOrder(a, b) {
|
|
709
707
|
return a.order - b.order;
|
|
710
708
|
}
|
|
711
709
|
export function resolveReturn(value) {
|
|
@@ -714,4 +712,4 @@ export function resolveReturn(value) {
|
|
|
714
712
|
export function rejectRethrow(error) {
|
|
715
713
|
throw error;
|
|
716
714
|
}
|
|
717
|
-
|
|
715
|
+
Launch.init();
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MemberOptions } from './Options.js';
|
|
2
|
-
export declare abstract class Controller<T> {
|
|
3
|
-
abstract readonly options: MemberOptions;
|
|
4
|
-
abstract readonly args: ReadonlyArray<any>;
|
|
5
|
-
abstract readonly result: T;
|
|
6
|
-
abstract readonly error: any;
|
|
7
|
-
abstract readonly stamp: number;
|
|
8
|
-
abstract readonly isUpToDate: boolean;
|
|
9
|
-
abstract configure(options: Partial<MemberOptions>): MemberOptions;
|
|
10
|
-
abstract markObsolete(): void;
|
|
11
|
-
abstract pullLastResult(args?: any[]): T | undefined;
|
|
12
|
-
}
|