Skip to content

Commit 50dd1fa

Browse files
committed
refactor(rx-*-directive): change how context object is updated
necessary change since replacing the whole context object on `ViewRef` is deprecated
1 parent aa450e3 commit 50dd1fa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libs/components/src/lib/rx/base-rx.directive.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DestroyRef, EmbeddedViewRef, inject, TemplateRef, Type, ViewContainerRe
22
import { from, isObservable, ObservableInput, Subscription } from 'rxjs'
33
import { ERROR_INPUT_NAME, RX_DEFAULT_ERROR_COMPONENT } from './internals'
44

5-
export abstract class BaseRxDirective<T, Ctx> {
5+
export abstract class BaseRxDirective<T, Ctx extends object> {
66
protected _input: ObservableInput<T> | null
77
protected _subscription: Subscription | null = null
88
protected _dataViewRef: EmbeddedViewRef<Ctx> | null = null
@@ -46,7 +46,10 @@ export abstract class BaseRxDirective<T, Ctx> {
4646
*/
4747
protected renderDataView(context: Ctx) {
4848
if (this._dataViewRef && this.containerRef.indexOf(this._dataViewRef) === 0) {
49-
this._dataViewRef.context = context
49+
const ctxKeys: Array<keyof Ctx> = Object.keys(context) as any
50+
for (const key of ctxKeys) {
51+
this._dataViewRef.context[key] = context[key]
52+
}
5053
} else {
5154
this.clear()
5255
this._dataViewRef = this.containerRef.createEmbeddedView(this.templateRef, context)

0 commit comments

Comments
 (0)