reactronic 0.21.519 → 0.21.520
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 +1 -1
- package/build/dist/source/Ref.d.ts +3 -3
- package/build/dist/source/Ref.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://circleci.com/gh/nezaboodka/reactronic)
|
|
7
7
|

|
|
8
8
|

|
|
9
|
-
[](https://gitlab.com/nezaboodka/nevod.
|
|
9
|
+
[](https://gitlab.com/nezaboodka/nevod.website/-/blob/master/README.md)
|
|
10
10
|
|
|
11
11
|
# **Reactronic** - Transactional Reactive State Management
|
|
12
12
|
|
|
@@ -27,8 +27,8 @@ export declare class Ref<T = any> {
|
|
|
27
27
|
static similarRefs(v1: Ref, v2: Ref): boolean;
|
|
28
28
|
}
|
|
29
29
|
export declare class ToggleRef<T = boolean> extends Ref<T> {
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
32
|
-
constructor(owner: any, name: string,
|
|
30
|
+
readonly valueOn: T;
|
|
31
|
+
readonly valueOff: T;
|
|
32
|
+
constructor(owner: any, name: string, valueOn: T, valueOff: T);
|
|
33
33
|
toggle(): void;
|
|
34
34
|
}
|
package/build/dist/source/Ref.js
CHANGED
|
@@ -49,22 +49,22 @@ class Ref {
|
|
|
49
49
|
}
|
|
50
50
|
exports.Ref = Ref;
|
|
51
51
|
class ToggleRef extends Ref {
|
|
52
|
-
constructor(owner, name,
|
|
52
|
+
constructor(owner, name, valueOn, valueOff) {
|
|
53
53
|
super(owner, name);
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
54
|
+
this.valueOn = valueOn;
|
|
55
|
+
this.valueOff = valueOff;
|
|
56
56
|
}
|
|
57
57
|
toggle() {
|
|
58
58
|
const o = this.owner;
|
|
59
59
|
const p = this.name;
|
|
60
60
|
Transaction_1.Transaction.runAs({ hint: `toggle ${o.constructor.name}.${p}` }, () => {
|
|
61
61
|
const v = o[p];
|
|
62
|
-
const
|
|
63
|
-
Ref.sameRefs(v, this.
|
|
64
|
-
if (!
|
|
65
|
-
o[p] = this.
|
|
62
|
+
const isOn = v === this.valueOn || (v instanceof Ref && this.valueOn instanceof Ref &&
|
|
63
|
+
Ref.sameRefs(v, this.valueOn));
|
|
64
|
+
if (!isOn)
|
|
65
|
+
o[p] = this.valueOn;
|
|
66
66
|
else
|
|
67
|
-
o[p] = this.
|
|
67
|
+
o[p] = this.valueOff;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
}
|