MCPcopy
hub / github.com/QwikDev/qwik / useVisibleTaskQrl

Function useVisibleTaskQrl

packages/qwik/src/core/use/use-task.ts:453–475  ·  view source on GitHub ↗
(qrl: QRL<TaskFn>, opts?: OnVisibleTaskOptions)

Source from the content-addressed store, hash-verified

451 */
452// </docs>
453export const useVisibleTaskQrl = (qrl: QRL<TaskFn>, opts?: OnVisibleTaskOptions): void => {
454 const { val, set, i, iCtx, elCtx } = useSequentialScope<Task<TaskFn>>();
455 const eagerness = opts?.strategy ?? 'intersection-observer';
456 if (val) {
457 if (isServerPlatform()) {
458 useRunTask(val, eagerness);
459 }
460 return;
461 }
462 assertQrl(qrl);
463 const task = new Task(TaskFlagsIsVisibleTask, i, elCtx.$element$, qrl, undefined);
464 const containerState = iCtx.$renderCtx$.$static$.$containerState$;
465 if (!elCtx.$tasks$) {
466 elCtx.$tasks$ = [];
467 }
468 elCtx.$tasks$.push(task);
469 set(task);
470 useRunTask(task, eagerness);
471 if (!isServerPlatform()) {
472 qrl.$resolveLazy$(containerState.$containerEl$);
473 notifyTask(task, containerState);
474 }
475};
476
477// <docs markdown="../readme.md#useVisibleTask">
478// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!

Callers

nothing calls this directly

Calls 6

useSequentialScopeFunction · 0.90
isServerPlatformFunction · 0.90
assertQrlFunction · 0.90
notifyTaskFunction · 0.90
useRunTaskFunction · 0.85
setFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…