(qrl: QRL<TaskFn>, opts?: OnVisibleTaskOptions)
| 451 | */ |
| 452 | // </docs> |
| 453 | export 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!!! |
nothing calls this directly
no test coverage detected
searching dependent graphs…