From 5fb8cece718858355003e1bd19aeb937e291813c Mon Sep 17 00:00:00 2001 From: kasparsj Date: Fri, 5 Jun 2020 23:14:16 +0300 Subject: [PATCH] fix previousValue in onChange for schema properties --- src/Schema.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Schema.ts b/src/Schema.ts index ff20848d..d76ab611 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -171,7 +171,7 @@ export abstract class Schema { let type = schema[field]; let value: any; - + let previousValue = this[_field]; let hasChange = false; if (!field) { @@ -182,6 +182,7 @@ export abstract class Schema { hasChange = true; } else if ((type as any)._schema) { + previousValue = previousValue && this[_field].clone(); value = this[_field] || this.createTypeInstance(bytes, it, type as typeof Schema); value.decode(bytes, it); @@ -397,7 +398,7 @@ export abstract class Schema { changes.push({ field, value, - previousValue: this[_field] + previousValue: previousValue }); }