(qrl: QRL<TaskFn>, opts?: UseTaskOptions)
| 278 | */ |
| 279 | // </docs> |
| 280 | export const useTaskQrl = (qrl: QRL<TaskFn>, opts?: UseTaskOptions): void => { |
| 281 | const { val, set, iCtx, i, elCtx } = useSequentialScope<boolean>(); |
| 282 | if (val) { |
| 283 | return; |
| 284 | } |
| 285 | assertQrl(qrl); |
| 286 | |
| 287 | const containerState = iCtx.$renderCtx$.$static$.$containerState$; |
| 288 | const task = new Task(TaskFlagsIsDirty | TaskFlagsIsTask, i, elCtx.$element$, qrl, undefined); |
| 289 | set(true); |
| 290 | qrl.$resolveLazy$(containerState.$containerEl$); |
| 291 | if (!elCtx.$tasks$) { |
| 292 | elCtx.$tasks$ = []; |
| 293 | } |
| 294 | elCtx.$tasks$.push(task); |
| 295 | waitAndRun(iCtx, () => runTask(task, containerState, iCtx.$renderCtx$)); |
| 296 | if (isServerPlatform()) { |
| 297 | useRunTask(task, opts?.eagerness); |
| 298 | } |
| 299 | }; |
| 300 | |
| 301 | /** @public */ |
| 302 | export const createComputedQrl = <T>(qrl: QRL<ComputedFn<T>>): Signal<Awaited<T>> => { |
no test coverage detected
searching dependent graphs…