Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e49a753

Browse files
committed
feat(template): deprecate parent flag
This flag is not needed anymore when using signal view / content queries. It will be dropped soon.
1 parent c8c8ced commit e49a753

File tree

8 files changed

+407
-129
lines changed

8 files changed

+407
-129
lines changed

libs/cdk/render-strategies/src/lib/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export interface RxRenderStrategiesConfig<T extends string> {
1111
primaryStrategy?: RxStrategyNames<T>;
1212
customStrategies?: RxCustomStrategyCredentials<T>;
1313
patchZone?: boolean;
14+
/**
15+
* @deprecated This flag will be dropped soon, as it is no longer required when using signal based view & content queries
16+
*/
1417
parent?: boolean;
1518
}
1619

@@ -31,7 +34,7 @@ export const RX_RENDER_STRATEGIES_DEFAULTS: Required<
3134
} as const;
3235

3336
export function mergeDefaultConfig<T extends string>(
34-
cfg?: RxRenderStrategiesConfig<T>
37+
cfg?: RxRenderStrategiesConfig<T>,
3538
): Required<RxRenderStrategiesConfig<T | RxDefaultStrategyNames>> {
3639
const custom: RxRenderStrategiesConfig<T> = cfg
3740
? cfg

libs/template/experimental/virtual-scrolling/src/lib/virtual-for.directive.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
235235
| Observable<(U & NgIterable<T>) | undefined | null>
236236
| (U & NgIterable<T>)
237237
| null
238-
| undefined
238+
| undefined,
239239
) {
240240
if (!isObservable(potentialObservable)) {
241241
this.staticValue = potentialObservable;
@@ -262,7 +262,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
262262
/** @internal */
263263
private strategyHandler = strategyHandling(
264264
this.strategyProvider.primaryStrategy,
265-
this.strategyProvider.strategies
265+
this.strategyProvider.strategies,
266266
);
267267
/**
268268
* @description
@@ -309,7 +309,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
309309
*/
310310
@Input('rxVirtualForStrategy')
311311
set strategy(
312-
strategyName: RxStrategyNames<string> | Observable<RxStrategyNames<string>>
312+
strategyName: RxStrategyNames<string> | Observable<RxStrategyNames<string>>,
313313
) {
314314
this.strategyHandler.next(strategyName);
315315
}
@@ -356,6 +356,8 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
356356
* }
357357
*
358358
* @param renderParent
359+
*
360+
* @deprecated this flag will be dropped soon, as it is no longer required when using signal based view & content queries
359361
*/
360362
@Input('rxVirtualForParent') renderParent = false;
361363

@@ -466,8 +468,8 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
466468
) {
467469
throw new Error(
468470
`trackBy must be typeof function or keyof T, but received ${JSON.stringify(
469-
trackByFnOrKey
470-
)}.`
471+
trackByFnOrKey,
472+
)}.`,
471473
);
472474
}
473475
if (trackByFnOrKey == null) {
@@ -523,7 +525,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
523525
* @param renderCallback
524526
*/
525527
@Input('rxVirtualForRenderCallback') set renderCallback(
526-
renderCallback: Subject<U>
528+
renderCallback: Subject<U>,
527529
) {
528530
this._renderCallback = renderCallback;
529531
}
@@ -561,7 +563,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
561563
readonly values$ = this.observables$.pipe(
562564
coerceObservableWith(),
563565
switchAll(),
564-
shareReplay({ bufferSize: 1, refCount: true })
566+
shareReplay({ bufferSize: 1, refCount: true }),
565567
);
566568

567569
/** @internal */
@@ -583,16 +585,16 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
583585
static ngTemplateContextGuard<
584586
T,
585587
U extends NgIterable<T> = NgIterable<T>,
586-
K = keyof T
588+
K = keyof T,
587589
>(
588590
dir: RxVirtualFor<T, U>,
589-
ctx: any
591+
ctx: any,
590592
): ctx is RxVirtualForViewContext<T, U, RxListViewComputedContext, K> {
591593
return true;
592594
}
593595

594596
constructor(
595-
private readonly templateRef: TemplateRef<RxVirtualForViewContext<T, U>>
597+
private readonly templateRef: TemplateRef<RxVirtualForViewContext<T, U>>,
596598
) {}
597599

598600
/** @internal */
@@ -637,9 +639,9 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
637639
Array.isArray(values)
638640
? values
639641
: values != null
640-
? Array.from(values)
641-
: []
642-
)
642+
? Array.from(values)
643+
: [],
644+
),
643645
),
644646
this.scrollStrategy.renderedRange$,
645647
this.strategyHandler.strategy$.pipe(distinctUntilChanged()),
@@ -667,7 +669,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
667669
changes,
668670
iterable,
669671
items.length,
670-
range.start
672+
range.start,
671673
);
672674
const updates = listChanges[0].sort((a, b) => a[0] - b[0]);
673675
const indicesToPosition = new Set<number>();
@@ -685,15 +687,15 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
685687
this.viewRendered$.next(update as any);
686688
}
687689
},
688-
{ ngZone: this.patchZone ? this.ngZone : undefined }
690+
{ ngZone: this.patchZone ? this.ngZone : undefined },
689691
);
690692
});
691693
this.partiallyFinished = true;
692694
const notifyParent = insertedOrRemoved && this.renderParent;
693695
this.renderingStart$.next(indicesToPosition);
694696
return combineLatest(
695697
// emit after all changes are rendered
696-
work$.length > 0 ? work$ : [of(iterable)]
698+
work$.length > 0 ? work$ : [of(iterable)],
697699
).pipe(
698700
tap(() => {
699701
this.templateManager.setItemCount(items.length);
@@ -719,16 +721,16 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
719721
{
720722
ngZone: this.patchZone ? this.ngZone : undefined,
721723
scope: (this.cdRef as any).context || this.cdRef,
722-
}
723-
).pipe(ignoreElements())
724-
)
724+
},
725+
).pipe(ignoreElements()),
726+
),
725727
)
726728
: (o$) => o$,
727729
this.handleError(),
728-
map(() => iterable)
730+
map(() => iterable),
729731
);
730732
}),
731-
this.handleError()
733+
this.handleError(),
732734
);
733735
}
734736

@@ -739,7 +741,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
739741
this.partiallyFinished = false;
740742
this.errorHandler.handleError(err);
741743
return of(null);
742-
})
744+
}),
743745
);
744746
}
745747

@@ -755,12 +757,12 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
755757
/** @internal */
756758
private createViewContext(
757759
item: T,
758-
computedContext: RxListViewComputedContext
760+
computedContext: RxListViewComputedContext,
759761
): RxVirtualForViewContext<T, U, RxListViewComputedContext> {
760762
return new RxVirtualForViewContext(
761763
item,
762764
this.values! as U,
763-
computedContext
765+
computedContext,
764766
);
765767
}
766768

@@ -770,7 +772,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
770772
view: EmbeddedViewRef<
771773
RxVirtualForViewContext<T, U, RxListViewComputedContext>
772774
>,
773-
computedContext?: RxListViewComputedContext
775+
computedContext?: RxListViewComputedContext,
774776
): void {
775777
view.context.updateContext(computedContext!);
776778
view.context.$implicit = item;

libs/template/for/src/lib/for.directive.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
118118
| Observable<(U & NgIterable<T>) | undefined | null>
119119
| (U & NgIterable<T>)
120120
| null
121-
| undefined
121+
| undefined,
122122
) {
123123
if (!isObservable(potentialObservable)) {
124124
this.staticValue = potentialObservable;
@@ -178,7 +178,7 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
178178
*/
179179
@Input()
180180
set rxForStrategy(
181-
strategyName: RxStrategyNames | Observable<RxStrategyNames> | undefined
181+
strategyName: RxStrategyNames | Observable<RxStrategyNames> | undefined,
182182
) {
183183
this.strategyInput$.next(strategyName);
184184
}
@@ -223,6 +223,8 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
223223
* }
224224
*
225225
* @param {boolean} renderParent
226+
*
227+
* @deprecated this flag will be dropped soon, as it is no longer required when using signal based view & content queries
226228
*/
227229
@Input('rxForParent') renderParent = this.strategyProvider.config.parent;
228230

@@ -329,8 +331,8 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
329331
) {
330332
console.warn(
331333
`trackBy must be a function, but received ${JSON.stringify(
332-
trackByFnOrKey
333-
)}.`
334+
trackByFnOrKey,
335+
)}.`,
334336
);
335337
}
336338
if (trackByFnOrKey == null) {
@@ -409,7 +411,7 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
409411
private readonly values$ = this.observables$.pipe(
410412
coerceObservableWith(),
411413
switchAll(),
412-
shareReplay({ refCount: true, bufferSize: 1 })
414+
shareReplay({ refCount: true, bufferSize: 1 }),
413415
);
414416

415417
/** @internal */
@@ -430,7 +432,7 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
430432
_distinctBy = (a: T, b: T) => a === b;
431433

432434
constructor(
433-
private readonly templateRef: TemplateRef<RxForViewContext<T, U>>
435+
private readonly templateRef: TemplateRef<RxForViewContext<T, U>>,
434436
) {}
435437

436438
/** @internal */
@@ -458,14 +460,14 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
458460
this._subscription.add(
459461
this.listManager
460462
.render(this.values$)
461-
.subscribe((v) => this._renderCallback?.next(v))
463+
.subscribe((v) => this._renderCallback?.next(v)),
462464
);
463465
}
464466

465467
/** @internal */
466468
createViewContext(
467469
item: T,
468-
computedContext: RxListViewComputedContext
470+
computedContext: RxListViewComputedContext,
469471
): RxForViewContext<T, U> {
470472
return new RxForViewContext<T, U>(item, this.values, computedContext);
471473
}
@@ -474,7 +476,7 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
474476
updateViewContext(
475477
item: T,
476478
view: EmbeddedViewRef<RxForViewContext<T>>,
477-
computedContext: RxListViewComputedContext
479+
computedContext: RxListViewComputedContext,
478480
): void {
479481
view.context.updateContext(computedContext);
480482
view.context.rxForOf = this.values;
@@ -498,7 +500,7 @@ export class RxFor<T, U extends NgIterable<T> = NgIterable<T>>
498500
static ngTemplateContextGuard<
499501
T,
500502
U extends NgIterable<T> = NgIterable<T>,
501-
K = keyof T
503+
K = keyof T,
502504
>(dir: RxFor<T, U>, ctx: any): ctx is RxForViewContext<T, U, K> {
503505
return true;
504506
}

0 commit comments

Comments
 (0)