Skip to content

Commit

Permalink
feat: 🎸 remove current source value
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeevKatz committed Oct 30, 2020
1 parent fef0d54 commit 8662b55
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ export class ControlValueTransformerDirective<S, T> implements OnChanges {
*/
controlValueTransformer: Transformer<S, T>;

/**
* Reference to the current incoming source value.
*/
currentSourceValue: S;

/**
* The original implementations of {@link ngControl.valueAccessor.writeValue}.
*/
Expand Down Expand Up @@ -69,7 +64,7 @@ export class ControlValueTransformerDirective<S, T> implements OnChanges {
registerOnChange = (onChange: (sourceValue: S) => void) => {
this.originalRegisterOnChange.call(this.ngControl.valueAccessor, (targetValue: T) => {
if (this.controlValueTransformer) {
const sourceValue = this.controlValueTransformer.toSource(targetValue, this.currentSourceValue);
const sourceValue = this.controlValueTransformer.toSource(targetValue);

if (this.rewriteValueOnChange) {
this.writeValue(sourceValue);
Expand All @@ -85,7 +80,6 @@ export class ControlValueTransformerDirective<S, T> implements OnChanges {
*/
writeValue = (sourceValue: S) => {
if (this.controlValueTransformer) {
this.currentSourceValue = sourceValue;
const targetValue = this.controlValueTransformer.toTarget(sourceValue);
this.originalWriteValue.call(this.ngControl.valueAccessor, targetValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export interface Transformer<S = unknown, T = unknown> {
/**
* Transforms the given target value (`T`) to the source value type (`S`).
*/
toSource: (targetValue: T, currentSourceValue: S) => S;
toSource: (targetValue: T) => S;
}

0 comments on commit 8662b55

Please sign in to comment.