@nu-art/ts-common 0.300.5 → 0.300.6
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 +1 -1
- package/utils/ui-tools.js +17 -5
package/package.json
CHANGED
package/utils/ui-tools.js
CHANGED
|
@@ -95,19 +95,31 @@ const awaitedDebounce = (params) => {
|
|
|
95
95
|
_clearTimeout('fallbackTimer');
|
|
96
96
|
};
|
|
97
97
|
return (...args) => {
|
|
98
|
-
return new Promise((resolve) => {
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
99
|
var _a, _b;
|
|
100
100
|
const timeout = (_a = params.timeout) !== null && _a !== void 0 ? _a : 500;
|
|
101
101
|
_clearTimeout('timer');
|
|
102
102
|
timers.timer = setTimeout(async () => {
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
try {
|
|
104
|
+
_clearTimeouts();
|
|
105
|
+
const result = await params.func(...args);
|
|
106
|
+
resolve(result);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
reject(err);
|
|
110
|
+
}
|
|
105
111
|
}, timeout);
|
|
106
112
|
if (!timers.fallbackTimer) {
|
|
107
113
|
const fallbackTimeout = (_b = params.fallbackTimeout) !== null && _b !== void 0 ? _b : 1000;
|
|
108
114
|
timers.fallbackTimer = setTimeout(async () => {
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
try {
|
|
116
|
+
_clearTimeouts();
|
|
117
|
+
const result = await params.func(...args);
|
|
118
|
+
resolve(result);
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
reject(err);
|
|
122
|
+
}
|
|
111
123
|
}, fallbackTimeout);
|
|
112
124
|
}
|
|
113
125
|
});
|