@zentryhq/ui-utils 1.0.0 → 1.0.2
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/dist/debounced-fetcher.js +12 -4
- package/package.json +1 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Resolvable } from "@zentryhq/utils/resolvable";
|
|
2
1
|
/**
|
|
3
2
|
* Debounces a fetchable function into a single call.
|
|
4
3
|
*/
|
|
@@ -10,8 +9,17 @@ export class DebounceFetcher {
|
|
|
10
9
|
this._batchableFetch = _batchableFetch;
|
|
11
10
|
}
|
|
12
11
|
fetch(args) {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
let resolve = () => { };
|
|
13
|
+
const promise = new Promise((r) => {
|
|
14
|
+
resolve = r;
|
|
15
|
+
});
|
|
16
|
+
this._aggregated.push({
|
|
17
|
+
resolvable: {
|
|
18
|
+
promise,
|
|
19
|
+
resolve,
|
|
20
|
+
},
|
|
21
|
+
args,
|
|
22
|
+
});
|
|
15
23
|
if (!this._rafId) {
|
|
16
24
|
this._rafId = requestAnimationFrame(() => {
|
|
17
25
|
const aggregated = [...this._aggregated];
|
|
@@ -28,6 +36,6 @@ export class DebounceFetcher {
|
|
|
28
36
|
void doThing();
|
|
29
37
|
});
|
|
30
38
|
}
|
|
31
|
-
return
|
|
39
|
+
return promise;
|
|
32
40
|
}
|
|
33
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zentryhq/ui-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "UI Utility module used by the team at Zentry",
|
|
5
5
|
"homepage": "https://github.com/zentryHQ/common",
|
|
6
6
|
"bugs": {
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@types/react-dom": "19.2.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@zentryhq/utils": "workspace:*",
|
|
48
47
|
"clsx": "^2.1.1",
|
|
49
48
|
"tailwind-merge": "^3.4.1"
|
|
50
49
|
}
|