refactor(infra): remove setimmediate (#7975)

This commit is contained in:
EYHN
2024-08-26 11:57:24 +00:00
parent 611925fa10
commit 9ea4aaaf37
6 changed files with 14 additions and 12 deletions

View File

@@ -122,9 +122,10 @@ export class ComponentCachePool {
try {
i[Symbol.dispose]();
} catch (err) {
setImmediate(() => {
// make a uncaught exception
setTimeout(() => {
throw err;
});
}, 0);
}
}
}

View File

@@ -93,21 +93,24 @@ export function effect(...args: any[]) {
const subscription = subject$.pipe.apply(subject$, args as any).subscribe({
next(value) {
const error = new EffectError('should not emit value', value);
setImmediate(() => {
// make a uncaught exception
setTimeout(() => {
throw error;
});
}, 0);
},
complete() {
const error = new EffectError('effect unexpected complete');
setImmediate(() => {
// make a uncaught exception
setTimeout(() => {
throw error;
});
}, 0);
},
error(error) {
const effectError = new EffectError('effect uncaught error', error);
setImmediate(() => {
// make a uncaught exception
setTimeout(() => {
throw effectError;
});
}, 0);
},
});

View File

@@ -458,7 +458,8 @@ export class LiveData<T = unknown>
const subscription = this.subscribe(v => {
if (predicate(v)) {
resolve(v as any);
setImmediate(() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Promise.resolve().then(() => {
subscription.unsubscribe();
});
}

View File

@@ -1,4 +1,3 @@
import 'setimmediate';
import '@affine/component/theme/global.css';
import '@affine/component/theme/theme.css';
import '@affine/core/bootstrap/preload';

View File

@@ -1 +0,0 @@
import 'setimmediate';

View File

@@ -1 +0,0 @@
import 'setimmediate';