Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(infra): remove setimmediate #7975

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/common/infra/src/framework/core/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ export class ComponentCachePool {
try {
i[Symbol.dispose]();
} catch (err) {
setImmediate(() => {
// make a uncaught exception
setTimeout(() => {
throw err;
});
}, 0);
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions packages/common/infra/src/livedata/effect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});

Expand Down
3 changes: 2 additions & 1 deletion packages/common/infra/src/livedata/livedata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/electron/renderer/shell/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'setimmediate';
import '@affine/component/theme/global.css';
import '@affine/component/theme/theme.css';
import '@affine/core/bootstrap/preload';
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/mobile/src/polyfill/set-immediate.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/frontend/web/src/polyfill/set-immediate.ts

This file was deleted.

Loading