Skip to content

Commit

Permalink
remove computed chore
Browse files Browse the repository at this point in the history
  • Loading branch information
Varixo committed Aug 9, 2024
1 parent 3ef8169 commit f287219
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 33 deletions.
2 changes: 0 additions & 2 deletions packages/qwik/src/core/use/use-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ export const runSubscriber2 = async (
assertEqual(!!(task.$flags$ & TaskFlags.DIRTY), true, 'Task is not dirty', task);
if (isResourceTask(task)) {
return runResource(task, container, host as fixMeAny);
} else if (isComputedTask(task)) {
return runComputed2(task, container, host);
} else {
return runTask2(task as Task, container, host);
}
Expand Down
39 changes: 8 additions & 31 deletions packages/qwik/src/core/v2/shared/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,15 @@ import { assertEqual } from '../../error/assert';
import type { QRLInternal } from '../../qrl/qrl-class';
import type { QRL } from '../../qrl/qrl.public';
import type { JSXOutput } from '../../render/jsx/types/jsx-node';
import {
Task,
TaskFlags,
cleanupTask,
runComputed2,
runSubscriber2,
type TaskFn,
} from '../../use/use-task';
import { Task, TaskFlags, cleanupTask, runTask2, type TaskFn } from '../../use/use-task';
import { isPromise, maybeThen, maybeThenPassError, safeCall } from '../../util/promises';
import type { ValueOrPromise } from '../../util/types';
import type { VirtualVNode } from '../client/types';
import { vnode_documentPosition, vnode_isVNode, vnode_setAttr } from '../client/vnode';
import { vnode_diff } from '../client/vnode-diff';
import { executeComponent2 } from './component-execution';
import type { Container2, HostElement, fixMeAny } from './types';
import { EffectSubscriptionsProp, isSignal2, type EffectSubscriptions } from '../signal/v2-signal';
import { isSignal2 } from '../signal/v2-signal';
import { serializeAttribute } from '../../render/execute-component';
import { type DomContainer } from '../client/dom-container';

Expand All @@ -113,9 +106,7 @@ export const enum ChoreType {
MICRO /* ***************** */ = 0b000_1111,

/** Ensure tha the QRL promise is resolved before processing next chores in the queue */
QRL_RESOLVE /* *********** */ = 0b000_0000,
// TODO(mhevery): COMPUTED should be deleted because it is handled synchronously.
COMPUTED /* ************** */ = 0b000_0001,
QRL_RESOLVE /* *********** */ = 0b000_0001,
RESOURCE /* ************** */ = 0b000_0010,
TASK /* ****************** */ = 0b000_0011,
NODE_DIFF /* ************* */ = 0b000_0100,
Expand Down Expand Up @@ -187,7 +178,6 @@ export const createScheduler = (
qrl: QRL<(...args: any[]) => any>,
props: any
): ValueOrPromise<JSXOutput>;
function schedule(type: ChoreType.COMPUTED, task: Task): ValueOrPromise<void>;
function schedule(
type: ChoreType.NODE_DIFF,
host: HostElement,
Expand All @@ -213,10 +203,7 @@ export const createScheduler = (
type !== ChoreType.WAIT_FOR_COMPONENTS &&
type !== ChoreType.COMPONENT_SSR;
const isTask =
type === ChoreType.TASK ||
type === ChoreType.VISIBLE ||
type === ChoreType.COMPUTED ||
type === ChoreType.CLEANUP_VISIBLE;
type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.CLEANUP_VISIBLE;
if (isTask) {
(hostOrTask as Task).$flags$ |= TaskFlags.DIRTY;
}
Expand Down Expand Up @@ -305,21 +292,11 @@ export const createScheduler = (
(err: any) => container.handleError(err, host)
);
break;
case ChoreType.COMPUTED:
returnValue = runComputed2(chore.$payload$ as Task<TaskFn, TaskFn>, container, host);
break;
case ChoreType.TASK:
const payload = chore.$payload$;
if (Array.isArray(payload)) {
// This is a hack to see if the scheduling will work.
const effectSubscriber = payload as fixMeAny as EffectSubscriptions;
const effect = effectSubscriber[EffectSubscriptionsProp.EFFECT];
returnValue = runSubscriber2(effect as Task<TaskFn, TaskFn>, container, host);
break;
}
// eslint-disable-next-line no-fallthrough
returnValue = runTask2(chore.$payload$ as Task<TaskFn, TaskFn>, container, host);
break;
case ChoreType.VISIBLE:
returnValue = runSubscriber2(chore.$payload$ as Task<TaskFn, TaskFn>, container, host);
returnValue = runTask2(chore.$payload$ as Task<TaskFn, TaskFn>, container, host);
break;
case ChoreType.CLEANUP_VISIBLE:
const task = chore.$payload$ as Task<TaskFn, TaskFn>;
Expand Down Expand Up @@ -503,7 +480,7 @@ function debugChoreToString(chore: Chore): string {
const type =
(
{
[ChoreType.COMPUTED]: 'COMPUTED',
[ChoreType.QRL_RESOLVE]: 'QRL_RESOLVE',
[ChoreType.RESOURCE]: 'RESOURCE',
[ChoreType.TASK]: 'TASK',
[ChoreType.NODE_DIFF]: 'NODE_DIFF',
Expand Down

0 comments on commit f287219

Please sign in to comment.