Skip to content

Commit c3b4975

Browse files
authored
Merge pull request #7532 from QwikDev/v2-more-explanations
chore: more functions explanations
2 parents 50141a9 + 1b0ebdb commit c3b4975

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/qwik/src/core/client/dom-container.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,23 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
375375
this.$serverData$ = { containerAttributes };
376376
}
377377

378+
/**
379+
* Schedule the initial QRLs to be resolved.
380+
*
381+
* Schedules the QRLs that are defined in the state data as `PreloadQRL`.
382+
*
383+
* This is done because when computed and custom serializer QRLs are called they need QRL to work.
384+
* If the QRL is not resolved at this point, it will be resolved by throwing a promise and
385+
* rerunning the whole wrapping function again. We want to avoid that, because it means that the
386+
* function can execute twice.
387+
*
388+
* ```ts
389+
* useVisibleTask$(() => {
390+
* runHeavyLogic(); // This will be called again if the QRL of `computedOrCustomSerializer` is not resolved.
391+
* console.log(computedOrCustomSerializer.value); // Throw a promise if QRL not resolved and execute visible task again.
392+
* });
393+
* ```
394+
*/
378395
private $scheduleInitialQRLs$(): void {
379396
if (this.$initialQRLsIndexes$) {
380397
for (const index of this.$initialQRLsIndexes$) {

packages/qwik/src/core/shared/shared-serialization.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,11 @@ export function _createDeserializeContainer(
15701570
}
15711571

15721572
/**
1573-
* Preprocess the state data to replace RootRef with the actual object.
1573+
* Preprocess the state data to:
1574+
*
1575+
* - Replace RootRef with the actual object
1576+
* - Create a map for forward refs
1577+
* - Create an array of indexes for initial QRLs
15741578
*
15751579
* Before:
15761580
*

0 commit comments

Comments
 (0)