|
|
@ -7,24 +7,20 @@
|
|
|
|
const r = Promise.withResolvers();
|
|
|
|
const r = Promise.withResolvers();
|
|
|
|
|
|
|
|
|
|
|
|
if (prev || v === '') {
|
|
|
|
if (prev || v === '') {
|
|
|
|
console.log('hello', !!prev)
|
|
|
|
|
|
|
|
Promise.resolve().then(async () => {
|
|
|
|
Promise.resolve().then(async () => {
|
|
|
|
console.log('count++')
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
r.resolve(v);
|
|
|
|
r.resolve(v);
|
|
|
|
await new Promise(r => setTimeout(r, 0));
|
|
|
|
await new Promise(r => setTimeout(r, 0));
|
|
|
|
// TODO with a microtask like below it still throws a mutation error
|
|
|
|
// TODO with a microtask like below it still throws a mutation error
|
|
|
|
// await Promise.resolve();
|
|
|
|
// await Promise.resolve();
|
|
|
|
prev?.resolve();
|
|
|
|
prev?.resolve();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.log('other')
|
|
|
|
|
|
|
|
prev = Promise.withResolvers();
|
|
|
|
prev = Promise.withResolvers();
|
|
|
|
prev.promise.then(() => {
|
|
|
|
prev.promise.then(() => {
|
|
|
|
console.log('other coun++')
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
r.resolve(v)
|
|
|
|
r.resolve(v)
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return r.promise;
|
|
|
|
return r.promise;
|
|
|
|