Skip to content

Commit 3e73b5d

Browse files
authored
Merge pull request #60 from shiftcode/#59-refactor-rx-directives-context-update
refactor(rx-*-directive): change how context object is updated
2 parents 7acd627 + 54bfa89 commit 3e73b5d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

libs/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shiftcode/ngx-components",
3-
"version": "12.0.1",
3+
"version": "12.0.2-pr59.0",
44
"repository": "https://github.com/shiftcode/sc-ng-commons-public",
55
"license": "MIT",
66
"author": "shiftcode GmbH <team@shiftcode.ch>",

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)