From 8681ad1254ffff2421b91d9965bdcd1f51651925 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Sat, 28 Sep 2024 16:15:03 +0800 Subject: [PATCH] Implement scheduler --- packages/runtime-vapor/src/renderEffect.ts | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/runtime-vapor/src/renderEffect.ts b/packages/runtime-vapor/src/renderEffect.ts index 5bce896be..35b3b6501 100644 --- a/packages/runtime-vapor/src/renderEffect.ts +++ b/packages/runtime-vapor/src/renderEffect.ts @@ -12,11 +12,7 @@ import { } from './scheduler' import { VaporErrorCodes, callWithAsyncErrorHandling } from './errorHandling' import { memoStack } from './memo' -import { - ReactiveEffect, - effect as effect2, - getCurrentScope, -} from '@johnsoncodehk/signals/vue' +import { ReactiveEffect, getCurrentScope } from '@johnsoncodehk/signals/vue' export function renderEffect(cb: () => void): void { const instance = getCurrentInstance() @@ -44,11 +40,15 @@ export function renderEffect(cb: () => void): void { memoCaches = memos.map(memo => memo()) } - const effect = effect2(() => - callWithAsyncErrorHandling(cb, instance, VaporErrorCodes.RENDER_FUNCTION), - ) + const effect = new ReactiveEffect(() => { + return callWithAsyncErrorHandling( + cb, + instance, + VaporErrorCodes.RENDER_FUNCTION, + ) + }) - // effect.scheduler = () => queueJob(job) + effect.scheduler = () => queueJob(job) // if (__DEV__ && instance) { // effect.onTrack = instance.rtc // ? e => invokeArrayFns(instance.rtc!, e) @@ -57,12 +57,12 @@ export function renderEffect(cb: () => void): void { // ? e => invokeArrayFns(instance.rtg!, e) // : void 0 // } - // effect.run() + effect.run() function job() { - // if (!(effect.flags & EffectFlags.ACTIVE) || !effect.dirty) { - // return - // } + if (!effect.dirty) { + return + } if (memos) { let dirty: boolean | undefined