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