@@ -96,7 +96,14 @@ import { isSignal, type Signal } from '../signal/signal.public';
96
96
import type { TargetType } from '../signal/store' ;
97
97
import type { ISsrNode } from '../ssr/ssr-types' ;
98
98
import { runResource , type ResourceDescriptor } from '../use/use-resource' ;
99
- import { Task , TaskFlags , cleanupTask , runTask , type TaskFn } from '../use/use-task' ;
99
+ import {
100
+ Task ,
101
+ TaskFlags ,
102
+ cleanupTask ,
103
+ runTask ,
104
+ type DescriptorBase ,
105
+ type TaskFn ,
106
+ } from '../use/use-task' ;
100
107
import { executeComponent } from './component-execution' ;
101
108
import type { OnRenderFn } from './component.public' ;
102
109
import { assertEqual , assertFalse } from './error/assert' ;
@@ -124,7 +131,6 @@ export const enum ChoreType {
124
131
/** Ensure that the QRL promise is resolved before processing next chores in the queue */
125
132
QRL_RESOLVE /* ********************** */ = 0b0000_0001 ,
126
133
RUN_QRL ,
127
- RESOURCE ,
128
134
TASK ,
129
135
NODE_DIFF ,
130
136
NODE_PROP ,
@@ -208,10 +214,7 @@ export const createScheduler = (
208
214
host : HostElement | null ,
209
215
target : Signal
210
216
) : ValueOrPromise < void > ;
211
- function schedule (
212
- type : ChoreType . TASK | ChoreType . VISIBLE | ChoreType . RESOURCE ,
213
- task : Task
214
- ) : ValueOrPromise < void > ;
217
+ function schedule ( type : ChoreType . TASK | ChoreType . VISIBLE , task : Task ) : ValueOrPromise < void > ;
215
218
function schedule (
216
219
type : ChoreType . RUN_QRL ,
217
220
host : HostElement ,
@@ -250,10 +253,7 @@ export const createScheduler = (
250
253
const runLater : boolean =
251
254
type !== ChoreType . WAIT_FOR_ALL && ! isComponentSsr && type !== ChoreType . RUN_QRL ;
252
255
const isTask =
253
- type === ChoreType . TASK ||
254
- type === ChoreType . VISIBLE ||
255
- type === ChoreType . RESOURCE ||
256
- type === ChoreType . CLEANUP_VISIBLE ;
256
+ type === ChoreType . TASK || type === ChoreType . VISIBLE || type === ChoreType . CLEANUP_VISIBLE ;
257
257
const isClientOnly =
258
258
type === ChoreType . JOURNAL_FLUSH ||
259
259
type === ChoreType . NODE_DIFF ||
@@ -399,22 +399,6 @@ export const createScheduler = (
399
399
) ;
400
400
}
401
401
break ;
402
- case ChoreType . RESOURCE :
403
- {
404
- const result = runResource (
405
- chore . $payload$ as ResourceDescriptor < TaskFn > ,
406
- container ,
407
- host
408
- ) ;
409
- // Don't await the return value of the resource, because async resources should not be awaited.
410
- // The reason for this is that we should be able to update for example a node with loading
411
- // text. If we await the resource, the loading text will not be displayed until the resource
412
- // is loaded.
413
- // Awaiting on the client also causes a deadlock.
414
- // In any case, the resource will never throw.
415
- returnValue = isServer ? result : null ;
416
- }
417
- break ;
418
402
case ChoreType . RUN_QRL :
419
403
{
420
404
const fn = ( chore . $target$ as QRLInternal < ( ...args : unknown [ ] ) => unknown > ) . getFn ( ) ;
@@ -444,7 +428,21 @@ export const createScheduler = (
444
428
break ;
445
429
case ChoreType . TASK :
446
430
case ChoreType . VISIBLE :
447
- returnValue = runTask ( chore . $payload$ as Task < TaskFn , TaskFn > , container , host ) ;
431
+ {
432
+ const payload = chore . $payload$ as DescriptorBase ;
433
+ if ( payload . $flags$ & TaskFlags . RESOURCE ) {
434
+ const result = runResource ( payload as ResourceDescriptor < TaskFn > , container , host ) ;
435
+ // Don't await the return value of the resource, because async resources should not be awaited.
436
+ // The reason for this is that we should be able to update for example a node with loading
437
+ // text. If we await the resource, the loading text will not be displayed until the resource
438
+ // is loaded.
439
+ // Awaiting on the client also causes a deadlock.
440
+ // In any case, the resource will never throw.
441
+ returnValue = isServer ? result : null ;
442
+ } else {
443
+ returnValue = runTask ( payload as Task < TaskFn , TaskFn > , container , host ) ;
444
+ }
445
+ }
448
446
break ;
449
447
case ChoreType . CLEANUP_VISIBLE :
450
448
{
@@ -677,7 +675,6 @@ function debugChoreTypeToString(type: ChoreType): string {
677
675
{
678
676
[ ChoreType . QRL_RESOLVE ] : 'QRL_RESOLVE' ,
679
677
[ ChoreType . RUN_QRL ] : 'RUN_QRL' ,
680
- [ ChoreType . RESOURCE ] : 'RESOURCE' ,
681
678
[ ChoreType . TASK ] : 'TASK' ,
682
679
[ ChoreType . NODE_DIFF ] : 'NODE_DIFF' ,
683
680
[ ChoreType . NODE_PROP ] : 'NODE_PROP' ,
0 commit comments