@neovici/cosmoz-utils 3.27.0 → 3.28.0
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/lib/haunted-polymer.js +1 -1
- package/lib/promise.js +19 -1
- package/package.json +1 -1
package/lib/haunted-polymer.js
CHANGED
|
@@ -87,7 +87,7 @@ export const hauntedPolymer = (outputPath, hook) => base => {
|
|
|
87
87
|
// render in the next animation frame to allow the haunted scheduler to finish processing the current state update
|
|
88
88
|
// otherwise hooks might be updated twice
|
|
89
89
|
cancelAnimationFrame(outlet.__renderAF);
|
|
90
|
-
outlet.__renderAF = requestAnimationFrame(() => render(part, outlet));
|
|
90
|
+
outlet.__renderAF = requestAnimationFrame(() => render(typeof part === 'function' ? part() : part, outlet));
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
};
|
package/lib/promise.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
class ManagedPromise extends Promise {
|
|
2
|
+
constructor(callback) {
|
|
3
|
+
const handles = {};
|
|
4
|
+
super((resolve, reject) => Object.assign(handles, { resolve, reject }));
|
|
5
|
+
Object.assign(this, handles);
|
|
6
|
+
callback?.(handles.resolve, handles.reject);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const timeout$ = ms => new Promise(res => setTimeout(res, ms)),
|
|
2
12
|
event$ = (target, type, predicate = () => true, timeout = 300000) =>
|
|
3
13
|
new Promise((resolve, reject) => {
|
|
4
14
|
let handler;
|
|
@@ -68,3 +78,11 @@ export const timeout$ = ms => new Promise(res => setTimeout(res, ms)),
|
|
|
68
78
|
pending.push({ resolve: res, reject: rej });
|
|
69
79
|
});
|
|
70
80
|
};
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
ManagedPromise,
|
|
84
|
+
timeout$,
|
|
85
|
+
event$,
|
|
86
|
+
limit$,
|
|
87
|
+
debounce$
|
|
88
|
+
};
|