evg_observable 1.4.35 → 1.4.36
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteFromArray = void 0;
|
|
3
|
+
exports.positiveCallback = exports.negativeCallback = exports.deleteFromArray = void 0;
|
|
4
4
|
function deleteFromArray(arr, component) {
|
|
5
5
|
const index = arr.indexOf(component);
|
|
6
6
|
if (index === -1)
|
|
@@ -12,3 +12,7 @@ function deleteFromArray(arr, component) {
|
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
14
|
exports.deleteFromArray = deleteFromArray;
|
|
15
|
+
const negativeCallback = () => false;
|
|
16
|
+
exports.negativeCallback = negativeCallback;
|
|
17
|
+
const positiveCallback = () => true;
|
|
18
|
+
exports.positiveCallback = positiveCallback;
|
package/src/outLib/Observable.js
CHANGED
|
@@ -92,32 +92,25 @@ class SubscribeObject {
|
|
|
92
92
|
return this;
|
|
93
93
|
}
|
|
94
94
|
unsubscribeByNegative(condition) {
|
|
95
|
-
|
|
96
|
-
condition = () => false;
|
|
97
|
-
this.unsubscribeByNegativeCondition = condition;
|
|
95
|
+
this.unsubscribeByNegativeCondition = !!condition ? condition : FunctionLibs_1.negativeCallback;
|
|
98
96
|
return this;
|
|
99
97
|
}
|
|
100
98
|
unsubscribeByPositive(condition) {
|
|
101
|
-
|
|
102
|
-
condition = () => true;
|
|
103
|
-
this.unsubscribeByPositiveCondition = condition;
|
|
99
|
+
this.unsubscribeByPositiveCondition = !!condition ? condition : FunctionLibs_1.positiveCallback;
|
|
104
100
|
return this;
|
|
105
101
|
}
|
|
106
102
|
emitByNegative(condition) {
|
|
107
|
-
|
|
108
|
-
condition = () => true;
|
|
109
|
-
this.emitByNegativeCondition = condition;
|
|
103
|
+
this.emitByNegativeCondition = !!condition ? condition : FunctionLibs_1.positiveCallback;
|
|
110
104
|
return this;
|
|
111
105
|
}
|
|
112
106
|
emitByPositive(condition) {
|
|
113
|
-
|
|
114
|
-
condition = () => false;
|
|
115
|
-
this.emitByPositiveCondition = condition;
|
|
107
|
+
this.emitByPositiveCondition = !!condition ? condition : FunctionLibs_1.negativeCallback;
|
|
116
108
|
return this;
|
|
117
109
|
}
|
|
118
110
|
emitMatch(condition) {
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
const type = typeof condition;
|
|
112
|
+
if (type !== "function") {
|
|
113
|
+
condition = () => `ERROR CONDITION TYPE ${type}, CONTROL STATE ${this.observable && !this.observable.getValue()}`;
|
|
121
114
|
}
|
|
122
115
|
this.emitMatchCondition = condition;
|
|
123
116
|
return this;
|