ngrx-store-localstorage icon indicating copy to clipboard operation
ngrx-store-localstorage copied to clipboard

checkStorageAvailability = true overwrites specified storage

Open zerodexter82 opened this issue 5 years ago • 1 comments

I'm trying to use this library to sync parts of my store to sessionStorage. The project uses SSR so we need to check for availability of storage. Unfortunately, it seems impossible to use the "storage" and "checkStorageAvailability" config options at the same time, because this code in localStorageSync function: if (config.storage === undefined && !config.checkStorageAvailability || (config.checkStorageAvailability && checkIsBrowserEnv()) ) { config.storage = localStorage || window.localStorage; }

will override config.storage to use localstorage if(config.checkStorageAvailability && checkIsBrowserEnv()).

Does anyone have alternative ideas on how to run this metaReducer conditionally only if inside a browser environment, with sessionStorage instead of localStorage?

zerodexter82 avatar Feb 17 '20 15:02 zerodexter82

It doesn't work for me either, they check IsBrowserEnv via

typeof window !== 'undefined'

but i have mocked window via domino in server.ts, so this check makes no sense

dmitry-kostin avatar May 14 '20 08:05 dmitry-kostin