1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix: removed overriding this-context for storage-adapter methods

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-03-03 18:33:18 +02:00
parent 7a3a2327ab
commit 76f9f3981d

View File

@ -89,23 +89,14 @@ export class StorageHelper<T = any> {
@action
private configure({ storage, observable }: StorageConfiguration<T> = this.options): this {
if (storage) this.configureStorage(storage);
if (storage) this.storage = storage;
if (observable) this.configureObservable(observable);
return this;
}
@action
protected configureStorage(storage: StorageAdapter<T>) {
this.storage = Object.getOwnPropertyNames(storage).reduce((storage, name: keyof StorageAdapter<T>) => {
storage[name] = storage[name]?.bind(this); // bind storage-adapter methods to "this"-context
return storage;
}, { ...storage });
}
@action
protected configureObservable(options: CreateObservableOptions = {}) {
private configureObservable(options: CreateObservableOptions = {}) {
this.data = observable.box<T>(this.data.get(), {
...StorageHelper.defaultOptions.observable, // inherit default observability options
...options,