mirror of
https://github.com/Doodle3D/Doodle3D-Core.git
synced 2024-12-22 11:03:48 +01:00
fix throttle
This commit is contained in:
parent
7fe47b78ca
commit
73764aed75
@ -43,21 +43,22 @@ export function asyncIterator(array, callback) {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
export function createThrottle() {
|
||||
function createThrottle() {
|
||||
let next = null;
|
||||
|
||||
return callback => {
|
||||
const startLoop = next === null;
|
||||
next = callback;
|
||||
|
||||
if (!startLoop) return;
|
||||
if (!startLoop) return null;
|
||||
|
||||
return (function loop() {
|
||||
return next().then(() => {
|
||||
return function loop() {
|
||||
const promise = next().then(() => {
|
||||
if (typeof next === 'function') return loop();
|
||||
});
|
||||
next = true;
|
||||
})().then(() => {
|
||||
return promise;
|
||||
}().then(() => {
|
||||
next = null;
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user