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
  {
2
2
  "name": "evg_observable",
3
- "version": "1.4.35",
3
+ "version": "1.4.36",
4
4
  "description": "Alternative fast and light library version - observable.",
5
5
  "directories": {
6
6
  "test": "test"
@@ -1 +1,3 @@
1
1
  export declare function deleteFromArray<T>(arr: T[], component: T): boolean;
2
+ export declare const negativeCallback: () => boolean;
3
+ export declare const positiveCallback: () => boolean;
@@ -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;
@@ -92,32 +92,25 @@ class SubscribeObject {
92
92
  return this;
93
93
  }
94
94
  unsubscribeByNegative(condition) {
95
- if (typeof condition !== "function")
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
- if (typeof condition !== "function")
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
- if (typeof condition !== "function")
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
- if (typeof condition !== "function")
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
- if (typeof condition !== "function") {
120
- condition = () => `ERROR CONDITION TYPE ${typeof condition}, CONTROL STATE ${this.observable && !this.observable.getValue()}`;
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;