File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,23 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
375
375
this . $serverData$ = { containerAttributes } ;
376
376
}
377
377
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
+ */
378
395
private $scheduleInitialQRLs$ ( ) : void {
379
396
if ( this . $initialQRLsIndexes$ ) {
380
397
for ( const index of this . $initialQRLsIndexes$ ) {
Original file line number Diff line number Diff line change @@ -1570,7 +1570,11 @@ export function _createDeserializeContainer(
1570
1570
}
1571
1571
1572
1572
/**
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
1574
1578
*
1575
1579
* Before:
1576
1580
*
You can’t perform that action at this time.
0 commit comments