Revert breaking change

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne SavolainenandMikko Aspiala committed 2022-01-10 16:54:04 +02:00
1 parent eeff7e488f
commit ae1d3a2712
1 file changed
+9 -7
+9 -7
View File
@@ -74,6 +74,11 @@ export class StorageHelper<T> {
this.storage = storage; 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) { if (autoInit) {
this.init(); this.init();
} }
@@ -133,6 +138,7 @@ export class StorageHelper<T> {
} }
} }
// @deprecated: Switch to using value for being reactive
get(): T { get(): T {
return this.value; return this.value;
} }
@@ -143,16 +149,12 @@ export class StorageHelper<T> {
} }
@action @action
set(newValue: T) { set(value: T) {
const oldValue = this.value; if (this.isDefaultValue(value)) {
if (this.isDefaultValue(newValue)) {
this.reset(); this.reset();
} else { } else {
this.data.set(newValue); this.data.set(value);
} }
this.onChange(newValue, oldValue);
} }
@action @action