diff --git a/src/asyncLocalStorage.ts b/src/asyncLocalStorage.ts index 4a91d52..16856d5 100644 --- a/src/asyncLocalStorage.ts +++ b/src/asyncLocalStorage.ts @@ -6,17 +6,18 @@ interface IAsyncLocalStorage { } export const AsyncLocalStorage: IAsyncLocalStorage = { + // must use wrapper functions when passing localStorage functions (https://github.com/agilgur5/mst-persist/issues/18) clear () { - return callWithPromise(window.localStorage.clear) + return callWithPromise(() => window.localStorage.clear()) }, getItem (key) { - return callWithPromise(window.localStorage.getItem, key) + return callWithPromise(() => window.localStorage.getItem(key)) }, removeItem (key) { - return callWithPromise(window.localStorage.removeItem, key) + return callWithPromise(() => window.localStorage.removeItem(key)) }, setItem (key, value) { - return callWithPromise(window.localStorage.setItem, key, value) + return callWithPromise(() => window.localStorage.setItem(key, value)) } }