From ae1d3a2712db41c24044ac24d1b0758271bc8a04 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Mon, 10 Jan 2022 15:10:53 +0200 Subject: [PATCH] Revert breaking change Co-authored-by: Mikko Aspiala Signed-off-by: Janne Savolainen --- src/renderer/utils/storageHelper.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/renderer/utils/storageHelper.ts b/src/renderer/utils/storageHelper.ts index bd240cea39..0fbb9e29db 100755 --- a/src/renderer/utils/storageHelper.ts +++ b/src/renderer/utils/storageHelper.ts @@ -74,6 +74,11 @@ export class StorageHelper { this.storage = storage; + // TODO: This code uses undocumented MobX internal to criminally permit exotic mutations without encapsulation. + this.data.observe_(({ newValue, oldValue }) => { + this.onChange(newValue as T, oldValue as T); + }); + if (autoInit) { this.init(); } @@ -133,6 +138,7 @@ export class StorageHelper { } } + // @deprecated: Switch to using value for being reactive get(): T { return this.value; } @@ -143,16 +149,12 @@ export class StorageHelper { } @action - set(newValue: T) { - const oldValue = this.value; - - if (this.isDefaultValue(newValue)) { + set(value: T) { + if (this.isDefaultValue(value)) { this.reset(); } else { - this.data.set(newValue); + this.data.set(value); } - - this.onChange(newValue, oldValue); } @action